Account: (login)

More Channels


Are you the publisher? Claim this channel

Search in 109,966,977 RSS articles:

Latest Articles in this Channel:

  • 12/13/11--07:42: problems with Ethernet shield & chapter 8 examples posted by roman plevka @ Tue, 13 Dec 2011 15:42:41 +0000 (chan 1547243)
  • Hey Marc,
    sorry for delayed answer.
    All I did was unpacking the tar file and running the arduino binary as it was…I had no problem with setting the right USB port, all settings (board, port) have been detected automatically.

    - btw. Server example is working fine, but I still experience problems with Client example. – still the same problem.

    - so I programmed the arduino under windows (I lost patience) on my other laptop.


  • 12/13/11--23:01: Temperature Sensor is Hot! posted by Jonas Andersson @ Wed, 14 Dec 2011 07:01:35 +0000 (chan 1547243)
  • Hey wonderful book thus far, I’m loving learning C at the same time as exploring the potential of micro-controllers.

    So, I was stepping through chapter 5, where we hook up the TMP36 to the Arduino and measure room temperature. I couldn’t quite figure out which pin was which, but i knew the center one was the signal pin. I wrote a program to just read the raw data off the signal pin and output it to the serial monitor. I ran it, observed some numbers scroll by on the monitor, and decided to put my fingers over the TMP36 to see if the numbers changed. OUCH! the thing put a blister on my index finger, and melted part of my breadboard it was so hot.

    Did I connect the sensor to the breadboard backwards? (My guess is yes ;]) but I’m just curious if this is normal, since I dont want to try it again and end up ordering more stuff.


  • 12/14/11--00:46: Temperature Sensor is Hot! posted by Maik Schmidt @ Wed, 14 Dec 2011 08:46:02 +0000 (chan 1547243)
  • Hi Jonas!

    First of all it’s great to hear that you like the book!

    Of course, connecting an electronic part incorrectly can (and possibly will) destroy the part :-(

    Did you know that you can find high resolution versions of all the book’s photos on Flickr?

    For example, you can see how to connect the TMP36 sensor here: http://www.flickr.com/photos/50804036@N06/51152…

    Hope this helps!

    Maik


  • 12/23/11--01:53: problems with Ethernet shield & chapter 8 examples posted by Jack @ Fri, 23 Dec 2011 09:53:20 +0000 (chan 1547243)
  • Hey Mark,
    I seem have the same problem to you.


  • 12/24/11--14:14: Ch 7 Nunchuk example code not consistent with Arduino 1.0 posted by L Abdulezer @ Sat, 24 Dec 2011 22:14:47 +0000 (chan 1547243)
  • First let me compliment you on writing a very clearly written book. In following the example for Chapter 7 on the Nunchuk interfacing (NunchukDemo.pde) I get the following sets of problems:

    “As of Arduino 1.0, the Wire.send() function was renamed to Wire.write() for consistency with other libraries.”

    No problem, I go ahead and make the changes from send to write in the nunchuk.cpp file, and then when I try to recompile I receive the following error message:

    “call of overloaded ‘write(int)’ is ambiguous”

    Can you please advise on how to correct the code?

    Thanks!


  • 12/24/11--23:37: Ch 7 Nunchuk example code not consistent with Arduino 1.0 posted by Maik Schmidt @ Sun, 25 Dec 2011 07:37:20 +0000 (chan 1547243)
  • You only have to slightly change the code to make it compile.

    • Replace #include <WProgram.h> with #include <Arduino.h> in the first line.
    • Replace all calls to send() with write() and cast the argument to byte. For example, use Wire.write((byte)0x40) instead of Wire.send(0x40).
    • Replace Wire.receive() with Wire.read().

    Cheers,

    Maik


  • 12/25/11--21:21: Ch 7 Nunchuk example code not consistent with Arduino 1.0 posted by L Abdulezer @ Mon, 26 Dec 2011 05:21:02 +0000 (chan 1547243)
  • Maik,

    Thank you very much. I applied the changes you suggested and it worked right away.

    When I ran the code there was something rather curious… when I press the zButton, the values for both the nunchuk.z_button() and nunchuk.c_button() change from 0 to 1. Whereas when I press the cButton, only nunchuk.c_button() changes from 0 to 1. Is there the intended behavior?

    Thanks to much.


  • 12/25/11--23:11: Ch 7 Nunchuk example code not consistent with Arduino 1.0 posted by Maik Schmidt @ Mon, 26 Dec 2011 07:11:11 +0000 (chan 1547243)
  • Thank you very much. I applied the changes you suggested and it worked right away.

    You’re welcome!

    When I ran the code there was something rather curious… when I press the zButton, the values for both the
    >nunchuk.z_button() and nunchuk.c_button() change from 0 to 1. Whereas when I press the cButton, only
    >nunchuk.c_button() changes from 0 to 1. Is there the intended behavior?

    This is not the intended behavior. When you do not press a button the corresponding function should return 0. Otherwise, it should return 1. Did you type in the code or did you download it from the book’s web site?

    Cheers,

    Maik


  • 12/26/11--07:51: Ch 7 Nunchuk example code not consistent with Arduino 1.0 posted by L Abdulezer @ Mon, 26 Dec 2011 15:51:03 +0000 (chan 1547243)
  • This was the downloaded code with code changes you suggested for use with Arduino 1.0 only on the file ‘nunchuk.cpp’. The contents of theo other files nunchuk.h and NunchukDemo.ino remain unaltered.


  • 12/26/11--11:26: Ch 7 Nunchuk example code not consistent with Arduino 1.0 posted by Maik Schmidt @ Mon, 26 Dec 2011 19:26:13 +0000 (chan 1547243)
  • This is strange. I’ve tried the code with a Nunchuk a few hours ago and it worked perfectly fine. Did you double check the wiring? At http://www.flickr.com/photos/50804036@N06/51189… you can see a high-resolution photo of the final circuit.

    Cheers,

    Maik


  • 12/26/11--14:59: Ch 7 Nunchuk example code not consistent with Arduino 1.0 posted by L Abdulezer @ Mon, 26 Dec 2011 22:59:01 +0000 (chan 1547243)
  • I checked to see that the wiring matches up, and it does. I ran the code once more (and I literally haven’t made any changes since yesterday when i posted the last set of messages) and now it works perfectly… go figure! Well thanks for taking the time to address this. Your comments on how to adjust to the new Arduino 1.0 version were extremely helpful. Once again, I have to say your book is excellent and I am obtaining great value from it.


  • 01/03/12--01:35: A Note regarding Chapter 5 posted by Misery @ Tue, 03 Jan 2012 09:35:55 +0000 (chan 1547243)
  • OH yes,Sven. I just have the same problem. Thank you.


  • 01/03/12--13:04: Pin HIGH vs LOW for output control... posted by David Keasey @ Tue, 03 Jan 2012 21:04:33 +0000 (chan 1547243)
  • I’m new at this, so please bear with… I suspect the answer is more about programming style than fundamental characteristics of the Arduino, but I’ll ask anyway.

    In a lot of the book examples you use the Arduino output pins as current sinks, rather than sources. For example, when controlling an LED, you wire the board, and set up the logic so that when a pin is LOW an LED will come on, and when that pin is HIGH the LED will be off. I’ve seen it done just the opposite, however, in tutorials from other sources.

    Is there a particular reason to use the Arduino output pin as a current sink instead of a current source?

    Thanks!


  • 01/03/12--23:09: Pin HIGH vs LOW for output control... posted by Maik Schmidt @ Wed, 04 Jan 2012 07:09:25 +0000 (chan 1547243)
  • Hi David!

    I’m afraid I do not fully understand your question. To turn on a LED you have to set the pin it’s connected to to HIGH. That’s what I do in the examples. Do you have a particular piece of sample code that you do not understand?

    Cheers,
    Maik


  • 01/04/12--08:28: Telegraph compilation, Arduino 1.0 posted by Henri Blumenstiel @ Wed, 04 Jan 2012 16:28:30 +0000 (chan 1547243)
  • Hi Maik,
    first of all thank’s a lot for your very useful book ‘Arduino’. Now I’m looking forward to write my code a little bit more methodically! The Telegraph example works well when I use the Arduino 0022 release but with the last one the following error message occurs: core.a(main.cpp.o): In function `main’: /Applications/Arduino_23.app/Contents/Resources/Java/hardware/arduino/cores/arduino/main.cpp:11: undefined reference to `setup’ /Applications/Arduino_23.app/Contents/Resources/Java/hardware/arduino/cores/arduino/main.cpp:14: undefined reference to `loop’
    Before compilation I replaced WProgram.h with Arduino.h as you recommended. In the main.cpp the Arduino.h file is included too and in the Arduino.h, setup() and loop() are declared.
    What’s going wrong ?
    Kind regards, Henri


  • 01/04/12--09:25: Telegraph compilation, Arduino 1.0 posted by Maik Schmidt @ Wed, 04 Jan 2012 17:25:20 +0000 (chan 1547243)
  • Hi Henri!

    I see the same error message when I compile the Telegraph.pde sketch directly. I do not know why that happens and I’ll have a look at it.

    But it’s not a big problem, because when you copy the Telegraph files to Arduino’s libraries folder (as described in the book) then everything works fine.

    Because of the stricter warning level of Arduino 1.0 you’ll see a couple of warnings. You can eliminate most of them by replacing char* LETTERS and char* DIGITS with const char* LETTERS and const char* LETTERS. Also you have to use unsigned values for loop counters, that is, use for (unsigned int i ... instead of for (int i ....

    Cheers,

    Maik


  • 01/04/12--10:03: Pin HIGH vs LOW for output control... posted by David Keasey @ Wed, 04 Jan 2012 18:03:11 +0000 (chan 1547243)
  • Sorry, Maik, but I think I got confused by a sentence in the book… I was looking at the discussion of the UnreliableSwithch.pde sketch on page 58, where you say that the led_state variable is set to LOW when the LED is on, and HIGH when it is off, and also seeing in your code that you used the led_state variable as a parameter in the digitalWrite statement.

    After looking it over some more, I understand my error.

    As a practical matter, however, I don’t see why one couldn’t use the pin as a sink… just hook the LED cathode to the pin, the anode to +5 Volts, and throw in a series resistor for protection. With the pin HIGH, the LED would be off; LOW would take the pin to ground and the LED should light. It makes for confusing code, but wouldn’t that work?


  • 01/04/12--10:32: Pin HIGH vs LOW for output control... posted by Maik Schmidt @ Wed, 04 Jan 2012 18:32:21 +0000 (chan 1547243)
  • As a practical matter, however, I don’t see why one couldn’t use the pin as a sink…
    >just hook the LED cathode to the pin, the anode to +5 Volts, and throw in a series resistor for protection.
    >With the pin HIGH, the LED would be off; LOW would take the pin to ground and the LED should light.
    >It makes for confusing code, but wouldn’t that work?

    That won’t work, because diodes – and a Light Emitting Diode is still a diode – let current pass only in one direction. So you have to wire it the right way.


  • 01/04/12--11:12: Pin HIGH vs LOW for output control... posted by David Keasey @ Wed, 04 Jan 2012 19:12:24 +0000 (chan 1547243)
  • Are you sure about that, Maik? Last I checked, if I wire the anode of a Light Emitting Diode to a +5 volt source, and the cathode to ground (through the appropriate resistor), it will light. If you wire it the other way, with the cathode at +5 Volts, the anode to ground, the LED won’t light.

    Just to be sure, I wrote a quick sketch to do just this, and it does work. Just the void loop part:

    void loop() {
    digitalWrite (12,LOW);
    delay(500);
    digitalWrite (12,HIGH);
    delay(1500);
    }

    I wired the anode of the LED to +5 volts, then wired from the cathode through a 330 Ohm resistor to pin12.
    The sketch runs just fine, and the LED blinks for 1/2 second on, 1.5 seconds off.

    Anyway, back to the basic question, is there a good reason other than programming style that one should avoid using arduino output pins as current sinks?

    Thanks!


  • 01/04/12--23:40: Pin HIGH vs LOW for output control... posted by Maik Schmidt @ Thu, 05 Jan 2012 07:40:18 +0000 (chan 1547243)
  • Hm, I am surprised that you could wire the LED the “wrong” way.

    Anyway, I had to do some research myself to learn about the Arduino’s sink/source behavior and I’ve found a nice explanation: http://liudr.wordpress.com/2011/10/16/sourcing-...


  • 01/05/12--10:01: Pin HIGH vs LOW for output control... posted by David Keasey @ Thu, 05 Jan 2012 18:01:27 +0000 (chan 1547243)
  • Thanks for that link! I’m guessing that some microcontrollers use diode protection on their pins, which would prevent using them as current sinks. The ATMEGA chips must not do this.

    Having a little programming experience, I expect that using the pins as sinks would result in some very confusing code. If one were to use this “feature” I would want to see very clear code documentation and commenting to make sure that someone reviewing the code later could have a very good understanding of what is being done and just why this unconventional approach is the best way to do it. C code can be bewildering enough as it is, especially when the programmer is showing off to demonstrate just how few lines are needed for a particular task.


  • 01/15/12--08:21: Dice Game Exercise posted by Derek @ Sun, 15 Jan 2012 16:21:16 +0000 (chan 1547243)
  • I’m having trouble with the first exercise in the Binary Dice chapter. I understand for example how the digitalWrite(result & B001) works, but can not figure out how to use a number to turn on a series of LEDs. Any help would be much appreciated.

    Also (and maybe this is my problem), I don’t really understand line 34 of the code “output_result(guess);”. It seems to me that the output_result() function defined later in the code only contains the variable “result”. Why does it work with “result” as well as with “guess”?

    So far the book has been great. I’d just like to make sure I’m understanding everything before moving forward.


  • 01/15/12--08:42: Dice Game Exercise posted by Derek @ Sun, 15 Jan 2012 16:42:22 +0000 (chan 1547243)
  • I did get this to work, but I’m not sure that it is the best way to go about this program? And still I am unsure about the output_result() function.

    void output_result(const long result) { if (result 1){ digitalWrite(LEDa, LOW); digitalWrite(LEDb, LOW); digitalWrite(LEDc, LOW); digitalWrite(LEDd, HIGH); digitalWrite(LEDe, LOW); digitalWrite(LEDf, LOW); digitalWrite(LEDg, LOW); } if (result 2){ digitalWrite(LEDa, HIGH); digitalWrite(LEDb, LOW); digitalWrite(LEDc, LOW); digitalWrite(LEDd, LOW); digitalWrite(LEDe, LOW); digitalWrite(LEDf, LOW); digitalWrite(LEDg, HIGH); } if (result 3){ digitalWrite(LEDa, HIGH); digitalWrite(LEDb, LOW); digitalWrite(LEDc, LOW); digitalWrite(LEDd, HIGH); digitalWrite(LEDe, LOW); digitalWrite(LEDf, LOW); digitalWrite(LEDg, HIGH); } if (result 4){ digitalWrite(LEDa, HIGH); digitalWrite(LEDb, LOW); digitalWrite(LEDc, HIGH); digitalWrite(LEDd, LOW); digitalWrite(LEDe, HIGH); digitalWrite(LEDf, LOW); digitalWrite(LEDg, HIGH); } if (result 5){ digitalWrite(LEDa, HIGH); digitalWrite(LEDb, LOW); digitalWrite(LEDc, HIGH); digitalWrite(LEDd, HIGH); digitalWrite(LEDe, HIGH); digitalWrite(LEDf, LOW); digitalWrite(LEDg, HIGH); } if (result 6){ digitalWrite(LEDa, HIGH); digitalWrite(LEDb, HIGH); digitalWrite(LEDc, HIGH); digitalWrite(LEDd, LOW); digitalWrite(LEDe, HIGH); digitalWrite(LEDf, HIGH); digitalWrite(LEDg, HIGH); }
    }


  • 01/15/12--09:35: Dice Game Exercise posted by Maik Schmidt @ Sun, 15 Jan 2012 17:35:42 +0000 (chan 1547243)
  • Hi Derek!

    This might be not the most elegant way to solve the problem, but if it works, it is just fine!

    Of course, you could try to find an algorithm using less statements. For example, you could represent the dice’s LEDs as an array and turn the current result into a binary number. Then you’d iterate over the bits of the binary number and control the LEDs accordingly.

    But for this example your solution is absolutely sufficient.

    Regarding your question about the output_result function: this function outputs an integer number as blinking LEDs and it does not care where the number comes from. So it outputs the result of the roll of a dice as well as a user’s guess.

    Cheers,

    Maik


  • 01/16/12--15:15: USB Removal posted by Dean Larsen @ Mon, 16 Jan 2012 23:15:40 +0000 (chan 1547243)
  • Hello:
    I’m new to using Arduino Uno. As with most USB devices, the user is generally expected to safely remove the USB device. When I’m using the Arduino Uno (on Linux), I cannot find a way to do this.

    Is it ok to simply remove the USB connector without sending a pc command?