Show Posts
Pages: 1 ... 16 17 [18] 19
256  Using Arduino / Networking, Protocols, and Devices / Re: rf2401 problem with mega 2560 on: January 28, 2012, 06:36:30 am
Just tested 2 Nrf24L01 modules, one connected to an Uno the other to a Mega 2560. I tested them with the getting started sketch that comes with the library. In the sketch for the Mega I set (radio(49,53)) and set pinMode 53 to output. I works but not like it should. About 80% of the pings times out when I transmit from the Mega, when I transmit from the Uno it's a little bit better (about 40% times out). Anyone have any ideas how I can improve this?
257  Using Arduino / Programming Questions / Re: Bytes to decimals to an integer? on: January 25, 2012, 04:24:21 pm
I think it should be 0x12? 18 in hex is 0x12, this works smiley
Thanks for the help.
258  Using Arduino / Programming Questions / Bytes to decimals to an integer? on: January 25, 2012, 04:09:28 pm
I started this from a sketch where a PIR detector turns on a light and after 30 seconds the light goes out. This works. Earlier this week I bought a little DS1307 module and hooked it up through I2C to my Arduino Uno. Now I want to only turn on the light in the evening (lets say after 18:00) and if the PIR detector is high. For the DS1307 module I used some code I found here ->
I can read the time from the DS1307 (serial monitor).
The only bit that doesn't work is this: "if (pirState == HIGH && (hour, DEC) >= 18)"  Do I need to convert the "hour"?
Could someone give me some pointers on how I can accomplish this?
This is the complete sketch:
  PIR detector turns on light, light switches automatically off after 30 seconds.
  Light must only turn on in the evening (after 18:00) 

#include <Wire.h>
const int DS1307_I2C_ADDRESS = 0x68;
const int pir = 2;     // the number of the PIR pin
const int light =  13;      // the number of the light pin

unsigned long on;      //start time for pir light on

int pirState = 0;         // variable for reading the pushbutton status

byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;

// Convert binary coded decimal to normal decimal numbers
byte bcdToDec(byte val)
  return ( (val/16*10) + (val%16) );

void getDateDs1307()
  // Reset the register pointer
  Wire.requestFrom(DS1307_I2C_ADDRESS, 7);
  // A few of these need masks because certain bits are control bits
  second     = bcdToDec(Wire.receive() & 0x7f);
  minute     = bcdToDec(Wire.receive());
  hour       = bcdToDec(Wire.receive() & 0x3f);  // Need to change this if 12 hour am/pm
  dayOfWeek  = bcdToDec(Wire.receive());
  dayOfMonth = bcdToDec(Wire.receive());
  month      = bcdToDec(Wire.receive());
  year       = bcdToDec(Wire.receive());

void setup() {
  pinMode(light, OUTPUT);     
  pinMode(pir, INPUT);

void loop(){

  Serial.println("  ");
  Serial.print(hour, DEC);
  Serial.print(minute, DEC);
  Serial.print(second, DEC);
  Serial.println("  ");
  Serial.print(month, DEC);
  Serial.print(dayOfMonth, DEC);
  Serial.println(year, DEC);
  delay(2000);   //slow down serial monitor for testing
  pirState = digitalRead(pir);

  if (pirState == HIGH && (hour, DEC) >= 18) {     
    digitalWrite(light, HIGH); 
    on = millis();

  unsigned long currentMillis = millis();

  if ((currentMillis - on) > 30000) {
    digitalWrite(light, LOW);

259  Using Arduino / General Electronics / Re: I2C and voltages on: January 24, 2012, 04:49:30 pm
I didn't know about the PCA9306, looks like a very easy solution if you want to combine 3,3 and 5V I2C devices. Will have to order one smiley Thanks for the info.
260  Using Arduino / Project Guidance / Re: Getting the Accelerometer (ADXL345) to work on: January 23, 2012, 11:47:26 am
The ADXL345 that I have doesn't "start" automatically, I have to sent a command to it before it starts sending data. I don't use the SPI bus like the sparkfun example but the I2C bus with the following library I did have some trouble to get it working, you can read about it on my blog.
261  Using Arduino / Project Guidance / Re: Multi Room Temperature Sensors and Reporting Station on: January 22, 2012, 10:25:46 am
Have a look at this:
262  Using Arduino / Project Guidance / Re: Mega 2560 with Ethernet shield on: January 22, 2012, 09:59:13 am
Have you tried the sketch that zoomkat posted? What does the serial monitor say? Have you tried pinging the ethernet shield from your computer? Is the IP that you used in the sketch in the same range as your computer?
263  Using Arduino / General Electronics / Re: I2C and voltages on: January 21, 2012, 06:39:37 pm
I've been playing with an ADXL345 accelerometer, also a 3,3V device connected to my Uno. I connected 2 4k7 resistors between SDA/SCL and 3,3V. Becomes more difficult when you want to combine 3,3 and 5V devices on the same I2C bus.
264  Using Arduino / Sensors / Re: Help with DHT11 on: January 19, 2012, 12:38:39 pm
Copy and paste did work!  I now need to get the code to calculate dew, convert the temp to F and get evevrything to return whole numbers only.  I am hoping to have my dht11 and my dallas onewires both integrated tonight.  I can get the dht11 to print to the lcd and separately get the onewire to print to lvd, but can't get them both to print.

Have a look at this -> there some code there that will be helpful smiley
265  Using Arduino / Project Guidance / Re: How do you power arduino with a 9V battery? on: January 19, 2012, 11:27:57 am
Very simple, have a look at this ->
266  Using Arduino / Microcontrollers / Re: Chinese clones on: January 13, 2012, 11:28:00 am
The first Arduino that I bought was a genuine Arduino from the official shop. I bought it for a friend that uses it to log the data of his solar panels. I now have an Uno and Mega2560 that I bought from Arduino-direct (Chinese webshop). Quality looks the same, I've had no trouble with the pin headers or anything else.
267  Using Arduino / Motors, Mechanics, and Power / Re: Reverse 28BYJ-48? How? on: January 11, 2012, 01:32:03 pm
@bajdi-  According to this thread:,85335.0.html

Your code should not work with the Stepper library to reverse the direction of a 28BYJ-48?
Are you sure it does go both ways CW and CCW?
How did you do it?

I started from the code I found here take a good look at how the pins are specified. I had no problem letting them turn both ways. I'll make a video if you don't believe me  smiley
268  Using Arduino / Motors, Mechanics, and Power / Re: Reverse 28BYJ-48? How? on: January 09, 2012, 02:38:49 pm
I have 2 of these little stepper motors. No problem to let them turn in both directions. What I haven't figured out is how many steps these little steppers really are. From testing I found out that I need to let them step more then 2000 steps for one rotation. I posted a sketch on my blog to control both steppers with a small joystick.
269  Using Arduino / Programming Questions / Re: Thermistor shield from arduino-direct on: January 06, 2012, 02:47:47 pm
I have a bunch of bricks from arduino-direct, they are made by Flamingo EDA. Look on the underside of the printboard. Mine all have - + and S markings, so no problem to connect them...
270  Using Arduino / Programming Questions / Re: Toggle leds on and off with IR remote control problem on: January 03, 2012, 11:48:50 am
Thanks very much for the help. I finally got it working smiley
This is the working sketch.
#include <IRremote.h> // use the library for IR

const int receiver = 11; // pin 1 of IR receiver to Arduino digital pin 11
const int led1 =  3;
const int led2 =  4;
const int led3 =  5;

IRrecv irrecv(receiver); // create instance of 'irrecv'

decode_results results;

boolean lightState1 = false;
boolean lightState2 = false;
boolean lightState3 = false;
unsigned long last1 = millis();
unsigned long last2 = millis();
unsigned long last3 = millis();

void setup()

  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);
  pinMode(led3, OUTPUT);

void loop()
  if (irrecv.decode(&results))
    if (results.value == 0xFF30CF)
      if (millis() - last1 > 300)
      lightState1 =!lightState1;
      last1 = millis();
    if (results.value == 0xFF18E7)
      if (millis() - last2 > 300)
      lightState2 =!lightState2;
      last2 = millis(); 

    if (results.value == 0xFF7A85)
       if (millis() - last3 > 300)
       lightState3 =!lightState3;
       last3 = millis();
Pages: 1 ... 16 17 [18] 19