Show Posts
Pages: 1 ... 3 4 [5]
61  Forum 2005-2010 (read only) / Syntax & Programs / Re: Strange PWM behaviour. on: October 02, 2010, 04:46:33 am
I also thought about that... Maybe I need to check it again smiley-wink
62  Forum 2005-2010 (read only) / Syntax & Programs / Strange PWM behaviour. on: October 01, 2010, 03:22:02 pm
Hi fellows, I have a strange 'problem'. I created a work around, but am still curious what could be the cause!

I'm connecting an H-bridge (L298N) unit ( to my Arduino and use (amongst others) this code:

uint8_t motor1_en = 9;
uint8_t motor1_dir = 8;
uint8_t motor2_en = 11;
uint8_t motor2_dir = 10;


digitalWrite(motor2_dir, HIGH);
analogWrite(motor2_en, motorspeed);

I was expecting (ergo: the information from that site has a sketch with that code), that the motors could be set using a value from 0..255 and setting the direction to low and/or high.
But... when I test it using my motor on output 2:
I need to set direction to HIGH and 0 is maximum speed forward, around 100 is minimum speed forward, 125 is about minimum speed backward and 255 is the maximum speed backward. That seems to be quite strange. I don't see any mistakes, I think that I have connected everything well. I know the atmega328 datasheet almost by heart (only 500+ pages smiley-wink).
63  Forum 2005-2010 (read only) / Syntax & Programs / Max7221 on analog pins with Duemilanove on: February 27, 2010, 07:16:20 am
I would like to connect the Max7221 to some analog pins due to lack of other pins. Reading the datasheet and following articles, this should be possible, but it doesn't work for some reason:


I have connected:
Data IN to pin 16
Load to pin 15
Clock to pin 14

Trying different things like making pins high and low, changing pins to in- and output didn't make it work. The print with LEDs does work when I connect it to normal pins (like 8, 9 and 10).

Thanks a lot for any hints.

-- source --
#include "LedControl.h"

int pin1 = 14, pin2 = 15, pin3 = 16;

LedControl lc = LedControl(pin3, pin2, pin1, 1);

void setup() {
  lc.shutdown(0, false);


void loop() {
  int i = 99;
  printNumber(i); // some method that lights up the display

64  Forum 2005-2010 (read only) / Syntax & Programs / Re: Serial input on: March 01, 2010, 02:10:47 am
So it is much easier to just use 0 or 1 and then use that in the rest of your program!

You can then make a variable e.g.:

int input =;

if (input == yes) {

if (input == no) { //could be done of couse also with else

65  Forum 2005-2010 (read only) / Troubleshooting / Re: IR receiving AND servo control... on: October 15, 2010, 04:09:44 am
for the time being I solved the problem using a different servo library that uses timer2 instead of timer0.

I might change the libary later.
66  Forum 2005-2010 (read only) / Troubleshooting / Re: IR receiving AND servo control... on: October 11, 2010, 02:25:13 pm
Well I think 4µs is. So I agree that that would be the best way. I have some good experiences with external interrupts, so let's try that then!!! Thanks a lot.
67  Forum 2005-2010 (read only) / Troubleshooting / Re: IR receiving AND servo control... on: October 11, 2010, 07:24:24 am
I'll take that into account. I know enough of the basics of the timers. Changing the whole IR code to external interrupts would best, but that is a next step I guess.
68  Forum 2005-2010 (read only) / Troubleshooting / Re: IR receiving AND servo control... on: October 11, 2010, 07:03:49 am
It is indeed the timer, stupid of me to overlook that!

Thanks a lot, I'll try another timer than for the IR stuff I suppose smiley
69  Forum 2005-2010 (read only) / Troubleshooting / IR receiving AND servo control... on: October 11, 2010, 02:15:21 am
I'm trying to use a remote control with a servo. I have the IR part already working well for quite some time.

#include <avr/interrupt.h>
#include <avr/io.h>

#include "myIRlib.h"
#include <Servo.h>

Servo myservo;
int IRpin = 2;
boolean changed = false;

void setup() {
  Serial.println("IR Remote");
  myservo.attach(6); // if I enable this line, no IR messages anymore!


void loop()
  digitalWrite(statusLed, LOW);
  if (IrRxFunctions.crunchIRData(IRpin) == 1) {
    // do something with the message...
    // ... bunch of lines here...

I don't know why, but as soon as I put myservo.attach in the code, my IR stops working... The IR functions currently don't use interrupts and that also may be the cause of the problem, but it should not be a problem should it?!
70  Forum 2005-2010 (read only) / Troubleshooting / Burning bootloader on Mac: troubles with mkII on: August 28, 2010, 02:48:43 am
I'm trying to use the mkII (usb on the JTAGICE version):

avrdude: usbdev_open(): did not find any USB device "usb"

I'm using Mac. On Windows I successfully managed to write to the AVR however (with AVR Studio 4).

In addition to that:
AVR Studio doesn't accept the optiboot 328 file although it seems optiboot is saying it should work for both the 168 and the 328.

I compiled the code for Atmega168. It uploads to the 168 but Arduino isn't very pleased with it:

avrdude: verification error, first mismatch at byte 0x0002
         0x36 != 0x34
avrdude: verification error; content mismatch
71  Forum 2005-2010 (read only) / Interfacing / Re: Help adapt AVR code for Stronglink RFID on: March 25, 2010, 04:20:06 pm
I'm also trying to get it to work, but I use the 18 (twi). I know that using RFID stuff can be quite hard. I have developed a desktop application for an industrial RFID unit and there was a lot of trouble with getting the bits right.
72  Forum 2005-2010 (read only) / Interfacing / Re: i2c / twi: issues with magnetic field? on: September 28, 2010, 01:54:58 am
The issue was a software problem in fact, so indeed the magnets aren't a problem.

But I still have another problem. If I send too many messages the arduino hangs. I know a way around it (just skipping most messages), but how could the hanging of the arduino be avoided? As soon as I disconnect the twi cable it goes further again.

current twi send code is:

void sendByteTWI(byte data) {

//and after an update:
void sendByteTWI(byte data) {
  if (lasttwicmd != data) {
    lasttwicmd = data;

Since I only need to toggle LEDs I never need to send the same command twice, so I ignore the same commands.
73  Forum 2005-2010 (read only) / Interfacing / i2c / twi: issues with magnetic field? on: September 28, 2010, 12:50:13 am
I'm using an Arduino to 'i2c' (that is not a verb but it should be I think smiley-wink) with another avr IC (2313). So far so good. However if I put the two in my final application (A LEGO train), it doesn't work anymore.
The signals don't seem to be received by the slave device.

Length of the cable is about 60 cm. I use two 1k5 pull-ups at the arduino side. I was wandering, could the magnets between the cars have something to do with this?!
74  Forum 2005-2010 (read only) / Exhibition / Re: Arduino Pong on: May 27, 2010, 11:49:06 am
Sorry for kicking the project, but it is worth it.

I have made this project and I have used (TIP!) two variable resistors for pin 8 (synch) and instead of the 75 Ohm. That makes it easier to reach those values.

The game works in part:
- startup is crystal (clear)
- playing is very bad, the problem is with the updates (they should fall between scanlines but they don't making the screen flicker)
- between two rounds (after a 'ball' is missed) the screen is nice again.

putting UPDATE_INTERVAL to 100 helps (although it flickers after that), but the games is unplayable then...

I use CLI so that should be ok. I have a duemilanove with an 328 uC.

It was caused by delayMicroseconds(10); around line 558. removing that made my game work at least smiley-wink.
75  Forum 2005-2010 (read only) / Exhibition / Re: Lego powerfunctions library on: March 13, 2010, 07:11:37 am
This is a nice one!!! Thanks a lot, it will be great to control LEGO PF Trains etc.
Pages: 1 ... 3 4 [5]