Show Posts
Pages: 1 [2] 3 4 ... 40
16  Community / Exhibition / Gallery / Re: TLC 5940 4x4x4 RGB LED cube on: June 03, 2014, 08:46:58 am
cool thanks for sharing
17  Topics / Science and Measurement / Re: Best logging site to use on: June 02, 2014, 06:59:53 am
Thanks for the replies. I can't find my old code. I a play over the weekend and got Xively working but not very impressed really, seems quite limited what it can do. Might have to check out Grovestreams
18  Topics / Science and Measurement / Re: Best logging site to use on: May 30, 2014, 04:03:27 am
Thanks Nick. It looks a lot more complicated than I remember - I will see if I can work it out though smiley
19  Topics / Science and Measurement / Best logging site to use on: May 29, 2014, 08:09:22 am
Hi all, I want to send data from a arduino to the cloud and be able to view on a graph. It has been a few years since I did anything like this, so long in fact that I cannot remember the name of the service that I used before, but I think I remember hearing that it dropped off the map anyhow.

What are people using these days?
20  Using Arduino / Programming Questions / checkString function causing issues on: February 12, 2014, 08:38:00 pm
Hi all. I am trying to read a string from a http request. It was working fine until I went to add more functions - one of those strings is called 'mode10' however, this string gets picked up when i check for a string called 'mode1'. I tried with other numbers and nothing >10 will work.

What is going on here? I thought it would check for the exact string including all characters but I guess as soon as it has a match it accepts it?

I can of course post the whole code if necessary but its rather long and badly structured at the moment

Code:
void checkString(){
  if(readString.indexOf("?mode1") >0)
  {
    if (debug == true)
      Serial.println("mode1");
    //starsTrue = false;
    mode = 1;
    mode1();
21  Using Arduino / Project Guidance / Re: DS1307 problem and DS3231 on: February 06, 2014, 11:02:10 am
I have the same problem with a ds1307 - the time keeping is useless! I wonder if I should try and change the xtal?

Does anyone know if the https://github.com/adafruit/RTClib will work with a DS3231?

Thanks
22  Using Arduino / Programming Questions / I'm trying to convert a string to a int on: February 05, 2014, 08:50:53 pm
I hope I'm on the right path here.. I have got a DS1307 hooked up with a uno and a 4 digit 7 seg display. I can display numbers that I enter into the following function
Code:
displayNumber(1234);

I think I need to convert the time into a string to give me the format I wish to display (Hour, Minutes). I have created a string to include the hours and minutes which prints out fine via serial, but I cant send the string to the display
Code:
displayNumber(string);


I have tired to convert the string into an int using atol - but no sucess. I get the following error
Quote
cannot convert 'String' to 'const char*' for argument '1' to 'long int atol(const char*)'

Could somebody please help me out? ( the segment of code I'm having trouble with is at the start of the loop() function)

Code:
/*
 6-13-2011
 Spark Fun Electronics 2011
 Nathan Seidle
 
 This code is public domain but you buy me a beer if you use this and we meet someday (Beerware license).
 
 4 digit 7 segment display:
 http://www.sparkfun.com/products/9483
 Datasheet:
 http://www.sparkfun.com/datasheets/Components/LED/7-Segment/YSD-439AR6B-35.pdf
 
 This is an example of how to drive a 7 segment LED display from an ATmega without the use of current limiting resistors.
 This technique is very common but requires some knowledge of electronics - you do run the risk of dumping too
 much current through the segments and burning out parts of the display. If you use the stock code you should be ok, but
 be careful editing the brightness values.
 
 This code should work with all colors (red, blue, yellow, green) but the brightness will vary from one color to the next
 because the forward voltage drop of each color is different. This code was written and calibrated for the red color.
 
 This code will work with most Arduinos but you may want to re-route some of the pins.
 
 7 segments
 4 digits
 1 colon
 =
 12 pins required for full control
 
 */
#include <Wire.h>
#include "RTClib.h"

RTC_DS1307 rtc;

#include <stdlib.h> // for the atol() function


int digit1 = 11; //PWM Display pin 1
int digit2 = 10; //PWM Display pin 2
int digit3 = 9; //PWM Display pin 6
int digit4 = 6; //PWM Display pin 8

//Pin mapping from Arduino to the ATmega DIP28 if you need it
//http://www.arduino.cc/en/Hacking/PinMapping
int segA = A1; //Display pin 14
int segB = 3; //Display pin 16
int segC = 4; //Display pin 13
int segD = 5; //Display pin 3
int segE = A0; //Display pin 5
int segF = 7; //Display pin 11
int segG = 8; //Display pin 15

int col = 13;

void setup() {  
  Serial.begin(57600);
#ifdef AVR
  Wire.begin();
#else
  Wire1.begin(); // Shield I2C pins connect to alt I2C bus on Arduino Due
#endif
  rtc.begin();

  if (! rtc.isrunning()) {
    Serial.println("RTC is NOT running!");
    // following line sets the RTC to the date & time this sketch was compiled
    //rtc.adjust(DateTime(__DATE__, __TIME__));
  }

  pinMode(segA, OUTPUT);
  pinMode(segB, OUTPUT);
  pinMode(segC, OUTPUT);
  pinMode(segD, OUTPUT);
  pinMode(segE, OUTPUT);
  pinMode(segF, OUTPUT);
  pinMode(segG, OUTPUT);

  pinMode(digit1, OUTPUT);
  pinMode(digit2, OUTPUT);
  pinMode(digit3, OUTPUT);
  pinMode(digit4, OUTPUT);
  pinMode(col, OUTPUT);

  pinMode(col, OUTPUT);
  digitalWrite(col, LOW);
}

void loop() {

  // find the time  
  DateTime now = rtc.now();
  byte hour = now.hour ();
  byte minute = now.minute ();

  String stringHour =  String(hour);    // converting a constant string into a String object
  String stringTime =  String(stringHour + minute);// concatenating two strings

  //stringOne.toInt();

  unsigned long num;
  num = atol(stringTime);
  Serial.println(num);


  displayNumber(num);
}

//Given a number, we display 10:22
//After running through the 4 numbers, the display is left turned off

//Display brightness
//Each digit is on for a certain amount of microseconds
//Then it is off until we have reached a total of 20ms for the function call
//Let's assume each digit is on for 1000us
//If each digit is on for 1ms, there are 4 digits, so the display is off for 16ms.
//That's a ratio of 1ms to 16ms or 6.25% on time (PWM).
//Let's define a variable called brightness that varies from:
//5000 blindingly bright (15.7mA current draw per digit)
//2000 shockingly bright (11.4mA current draw per digit)
//1000 pretty bright (5.9mA)
//500 normal (3mA)
//200 dim but readable (1.4mA)
//50 dim but readable (0.56mA)
//5 dim but readable (0.31mA)
//1 dim but readable in dark (0.28mA)

void displayNumber(int toDisplay) {
#define DISPLAY_BRIGHTNESS  50

#define DIGIT_ON  HIGH
#define DIGIT_OFF  LOW

  long beginTime = millis();

  for(int digit = 4 ; digit > 0 ; digit--) {

    //Turn on a digit for a short amount of time
    switch(digit) {
    case 1:
      digitalWrite(digit1, DIGIT_ON);
      break;
    case 2:
      digitalWrite(digit2, DIGIT_ON);
      break;
    case 3:
      digitalWrite(digit3, DIGIT_ON);
      break;
    case 4:
      digitalWrite(digit4, DIGIT_ON);
      break;
    }

    //Turn on the right segments for this digit
    lightNumber(toDisplay % 10);
    toDisplay /= 10;
    //toDisplay = 9;
    digitalWrite(col, HIGH); //turn on colon
    delayMicroseconds(DISPLAY_BRIGHTNESS); //Display this digit for a fraction of a second (between 1us and 5000us, 500 is pretty good)
    digitalWrite(col, LOW); //turn off colon
    //Turn off all segments
    lightNumber(10);

    //Turn off all digits
    digitalWrite(digit1, DIGIT_OFF);
    digitalWrite(digit2, DIGIT_OFF);
    digitalWrite(digit3, DIGIT_OFF);
    digitalWrite(digit4, DIGIT_OFF);
  }

  while( (millis() - beginTime) < 10) ; //Wait for 20ms to pass before we paint the display again
}

//Given a number, turns on those segments
//If number == 10, then turn off number
void lightNumber(int numberToDisplay) {

#define SEGMENT_ON  LOW
#define SEGMENT_OFF HIGH

  switch (numberToDisplay){

  case 0:
    digitalWrite(segA, SEGMENT_ON);
    digitalWrite(segB, SEGMENT_ON);
    digitalWrite(segC, SEGMENT_ON);
    digitalWrite(segD, SEGMENT_ON);
    digitalWrite(segE, SEGMENT_ON);
    digitalWrite(segF, SEGMENT_ON);
    digitalWrite(segG, SEGMENT_OFF);
    break;

  case 1:
    digitalWrite(segA, SEGMENT_OFF);
    digitalWrite(segB, SEGMENT_ON);
    digitalWrite(segC, SEGMENT_ON);
    digitalWrite(segD, SEGMENT_OFF);
    digitalWrite(segE, SEGMENT_OFF);
    digitalWrite(segF, SEGMENT_OFF);
    digitalWrite(segG, SEGMENT_OFF);
    break;

  case 2:
    digitalWrite(segA, SEGMENT_ON);
    digitalWrite(segB, SEGMENT_ON);
    digitalWrite(segC, SEGMENT_OFF);
    digitalWrite(segD, SEGMENT_ON);
    digitalWrite(segE, SEGMENT_ON);
    digitalWrite(segF, SEGMENT_OFF);
    digitalWrite(segG, SEGMENT_ON);
    break;

  case 3:
    digitalWrite(segA, SEGMENT_ON);
    digitalWrite(segB, SEGMENT_ON);
    digitalWrite(segC, SEGMENT_ON);
    digitalWrite(segD, SEGMENT_ON);
    digitalWrite(segE, SEGMENT_OFF);
    digitalWrite(segF, SEGMENT_OFF);
    digitalWrite(segG, SEGMENT_ON);
    break;

  case 4:
    digitalWrite(segA, SEGMENT_OFF);
    digitalWrite(segB, SEGMENT_ON);
    digitalWrite(segC, SEGMENT_ON);
    digitalWrite(segD, SEGMENT_OFF);
    digitalWrite(segE, SEGMENT_OFF);
    digitalWrite(segF, SEGMENT_ON);
    digitalWrite(segG, SEGMENT_ON);
    break;

  case 5:
    digitalWrite(segA, SEGMENT_ON);
    digitalWrite(segB, SEGMENT_OFF);
    digitalWrite(segC, SEGMENT_ON);
    digitalWrite(segD, SEGMENT_ON);
    digitalWrite(segE, SEGMENT_OFF);
    digitalWrite(segF, SEGMENT_ON);
    digitalWrite(segG, SEGMENT_ON);
    break;

  case 6:
    digitalWrite(segA, SEGMENT_ON);
    digitalWrite(segB, SEGMENT_OFF);
    digitalWrite(segC, SEGMENT_ON);
    digitalWrite(segD, SEGMENT_ON);
    digitalWrite(segE, SEGMENT_ON);
    digitalWrite(segF, SEGMENT_ON);
    digitalWrite(segG, SEGMENT_ON);
    break;

  case 7:
    digitalWrite(segA, SEGMENT_ON);
    digitalWrite(segB, SEGMENT_ON);
    digitalWrite(segC, SEGMENT_ON);
    digitalWrite(segD, SEGMENT_OFF);
    digitalWrite(segE, SEGMENT_OFF);
    digitalWrite(segF, SEGMENT_OFF);
    digitalWrite(segG, SEGMENT_OFF);
    break;

  case 8:
    digitalWrite(segA, SEGMENT_ON);
    digitalWrite(segB, SEGMENT_ON);
    digitalWrite(segC, SEGMENT_ON);
    digitalWrite(segD, SEGMENT_ON);
    digitalWrite(segE, SEGMENT_ON);
    digitalWrite(segF, SEGMENT_ON);
    digitalWrite(segG, SEGMENT_ON);
    break;

  case 9:
    digitalWrite(segA, SEGMENT_ON);
    digitalWrite(segB, SEGMENT_ON);
    digitalWrite(segC, SEGMENT_ON);
    digitalWrite(segD, SEGMENT_ON);
    digitalWrite(segE, SEGMENT_OFF);
    digitalWrite(segF, SEGMENT_ON);
    digitalWrite(segG, SEGMENT_ON);
    break;

  case 10:
    digitalWrite(segA, SEGMENT_OFF);
    digitalWrite(segB, SEGMENT_OFF);
    digitalWrite(segC, SEGMENT_OFF);
    digitalWrite(segD, SEGMENT_OFF);
    digitalWrite(segE, SEGMENT_OFF);
    digitalWrite(segF, SEGMENT_OFF);
    digitalWrite(segG, SEGMENT_OFF);
    break;
  }
}


23  Using Arduino / Project Guidance / Re: Cheap 7 segment & DS1307 clock project on: February 05, 2014, 08:19:14 pm
Thanks all for the help and sharing the code. I have worked it out now, it was extremely simple lol. I just have to insert a value into the displayNumber function smiley

Code:
displayNumber(millis()/1000);

now to try and work out how to create a string from the hour and minutes to display
24  Using Arduino / Project Guidance / Re: Cheap 7 segment & DS1307 clock project on: February 03, 2014, 06:48:16 am
Taken from the header on the example I'm using..
I think we would like to know where you found that code - I can't see the link to it on the page you cite.

The notion that it is OK if you overload the Arduino only part of the time is not likely to be seen too favorably by the people here.

What is really a concern also, is if for whatever reason, the code crashes while it is feeding excess current to a segment or group thereof.

Just commenting between cases here; haven't had a chance to look at the code as such ...


As stated in the OP the code is from Sparkfun. I'm aware that it is not the most foolproof way to connect LED's but I have never had a 328p crash on me yet.

@Krupski - thanks for the info! Those boards look interesting. I was hoping to check out the code because that is the part that I'm stuck on, I've got the 7 segment running nicely I just need to work out how to get it to display my time values  smiley-confuse

25  Using Arduino / Project Guidance / Re: Cheap 7 segment & DS1307 clock project on: February 02, 2014, 09:06:46 pm
What on earth makes you think that PWM is connected in some fashion with current limiting?   smiley-eek

Absolutely nothing.

Taken from the header on the example I'm using..
Quote
This is an example of how to drive a 7 segment LED display from an ATmega without the use of current limiting resistors.
 This technique is very common but requires some knowledge of electronics - you do run the risk of dumping too
 much current through the segments and burning out parts of the display. If you use the stock code you should be ok, but
 be careful editing the brightness values.

Any advise on the task of interfacing the code I'm using to read the time with the 7 segment example?

Thanks

26  Using Arduino / Project Guidance / Cheap 7 segment & DS1307 clock project on: February 02, 2014, 07:57:00 pm
Hi all. I'm attempting to make a simple clock on a budget. I have a 4 digital 7 segment display https://www.sparkfun.com/products/9483 and a DS1307 module.

I would like to simply display the hours and minutes, so I have got the following code ready for that..
Code:
// Date and time functions using a DS1307 RTC connected via I2C and Wire lib

#include <Wire.h>
#include "RTClib.h"

RTC_DS1307 rtc;

void setup () {
  Serial.begin(57600);
#ifdef AVR
  Wire.begin();
#else
  Wire1.begin(); // Shield I2C pins connect to alt I2C bus on Arduino Due
#endif
  rtc.begin();

  if (! rtc.isrunning()) {
    Serial.println("RTC is NOT running!");
    // following line sets the RTC to the date & time this sketch was compiled
    rtc.adjust(DateTime(__DATE__, __TIME__));
  }
}
void loop () {
    DateTime now = rtc.now();
    Serial.print(' ');
    Serial.print(now.hour(), DEC);
    Serial.print(':');
    Serial.print(now.minute(), DEC);
    Serial.println();
    delay(1000);
}

I have got the 7 segment display working from some code I found from sparkfun, which counts and displays the seconds using millis(). It uses PWM on the digit pins so I'm not using resistors which is handy.

The idea that I had was to convert the hours into a string, then add the minutes to the string, then update the display with that string - I've had no success in doing so. Any guidance would be gratefully received.

Code:
/*
 6-13-2011
 Spark Fun Electronics 2011
 Nathan Seidle
 
 This code is public domain but you buy me a beer if you use this and we meet someday (Beerware license).
 
 4 digit 7 segment display:
 http://www.sparkfun.com/products/9483
 Datasheet:
 http://www.sparkfun.com/datasheets/Components/LED/7-Segment/YSD-439AR6B-35.pdf
 
 This is an example of how to drive a 7 segment LED display from an ATmega without the use of current limiting resistors.
 This technique is very common but requires some knowledge of electronics - you do run the risk of dumping too
 much current through the segments and burning out parts of the display. If you use the stock code you should be ok, but
 be careful editing the brightness values.
 
 This code should work with all colors (red, blue, yellow, green) but the brightness will vary from one color to the next
 because the forward voltage drop of each color is different. This code was written and calibrated for the red color.
 
 This code will work with most Arduinos but you may want to re-route some of the pins.
 
 7 segments
 4 digits
 1 colon
 =
 12 pins required for full control
 
 */

int digit1 = 11; //PWM Display pin 1
int digit2 = 10; //PWM Display pin 2
int digit3 = 9; //PWM Display pin 6
int digit4 = 6; //PWM Display pin 8

//Pin mapping from Arduino to the ATmega DIP28 if you need it
//http://www.arduino.cc/en/Hacking/PinMapping
int segA = A1; //Display pin 14
int segB = 3; //Display pin 16
int segC = 4; //Display pin 13
int segD = 5; //Display pin 3
int segE = A0; //Display pin 5
int segF = 7; //Display pin 11
int segG = 8; //Display pin 15

int col = 13;

void setup() {               
  pinMode(segA, OUTPUT);
  pinMode(segB, OUTPUT);
  pinMode(segC, OUTPUT);
  pinMode(segD, OUTPUT);
  pinMode(segE, OUTPUT);
  pinMode(segF, OUTPUT);
  pinMode(segG, OUTPUT);

  pinMode(digit1, OUTPUT);
  pinMode(digit2, OUTPUT);
  pinMode(digit3, OUTPUT);
  pinMode(digit4, OUTPUT);
  pinMode(col, OUTPUT);

  pinMode(col, OUTPUT);
  digitalWrite(col, LOW);
}

void loop() {

  //long startTime = millis();

  displayNumber(millis()/1000);

  //while( (millis() - startTime) < 2000) {
  //displayNumber(1217);
  //}
  //delay(1000); 
}

//Given a number, we display 10:22
//After running through the 4 numbers, the display is left turned off

//Display brightness
//Each digit is on for a certain amount of microseconds
//Then it is off until we have reached a total of 20ms for the function call
//Let's assume each digit is on for 1000us
//If each digit is on for 1ms, there are 4 digits, so the display is off for 16ms.
//That's a ratio of 1ms to 16ms or 6.25% on time (PWM).
//Let's define a variable called brightness that varies from:
//5000 blindingly bright (15.7mA current draw per digit)
//2000 shockingly bright (11.4mA current draw per digit)
//1000 pretty bright (5.9mA)
//500 normal (3mA)
//200 dim but readable (1.4mA)
//50 dim but readable (0.56mA)
//5 dim but readable (0.31mA)
//1 dim but readable in dark (0.28mA)

void displayNumber(int toDisplay) {
#define DISPLAY_BRIGHTNESS  50

#define DIGIT_ON  HIGH
#define DIGIT_OFF  LOW

  long beginTime = millis();

  for(int digit = 4 ; digit > 0 ; digit--) {

    //Turn on a digit for a short amount of time
    switch(digit) {
    case 1:
      digitalWrite(digit1, DIGIT_ON);
      break;
    case 2:
      digitalWrite(digit2, DIGIT_ON);
      break;
    case 3:
      digitalWrite(digit3, DIGIT_ON);
      break;
    case 4:
      digitalWrite(digit4, DIGIT_ON);
      break;
    }

    //Turn on the right segments for this digit
    lightNumber(toDisplay % 10);
    toDisplay /= 10;
    //toDisplay = 9;
    digitalWrite(col, HIGH); //turn on colon
    delayMicroseconds(DISPLAY_BRIGHTNESS); //Display this digit for a fraction of a second (between 1us and 5000us, 500 is pretty good)
    digitalWrite(col, LOW); //turn off colon
    //Turn off all segments
    lightNumber(10);

    //Turn off all digits
    digitalWrite(digit1, DIGIT_OFF);
    digitalWrite(digit2, DIGIT_OFF);
    digitalWrite(digit3, DIGIT_OFF);
    digitalWrite(digit4, DIGIT_OFF);
  }

  while( (millis() - beginTime) < 10) ; //Wait for 20ms to pass before we paint the display again
}

//Given a number, turns on those segments
//If number == 10, then turn off number
void lightNumber(int numberToDisplay) {

#define SEGMENT_ON  LOW
#define SEGMENT_OFF HIGH

  switch (numberToDisplay){

  case 0:
    digitalWrite(segA, SEGMENT_ON);
    digitalWrite(segB, SEGMENT_ON);
    digitalWrite(segC, SEGMENT_ON);
    digitalWrite(segD, SEGMENT_ON);
    digitalWrite(segE, SEGMENT_ON);
    digitalWrite(segF, SEGMENT_ON);
    digitalWrite(segG, SEGMENT_OFF);
    break;

  case 1:
    digitalWrite(segA, SEGMENT_OFF);
    digitalWrite(segB, SEGMENT_ON);
    digitalWrite(segC, SEGMENT_ON);
    digitalWrite(segD, SEGMENT_OFF);
    digitalWrite(segE, SEGMENT_OFF);
    digitalWrite(segF, SEGMENT_OFF);
    digitalWrite(segG, SEGMENT_OFF);
    break;

  case 2:
    digitalWrite(segA, SEGMENT_ON);
    digitalWrite(segB, SEGMENT_ON);
    digitalWrite(segC, SEGMENT_OFF);
    digitalWrite(segD, SEGMENT_ON);
    digitalWrite(segE, SEGMENT_ON);
    digitalWrite(segF, SEGMENT_OFF);
    digitalWrite(segG, SEGMENT_ON);
    break;

  case 3:
    digitalWrite(segA, SEGMENT_ON);
    digitalWrite(segB, SEGMENT_ON);
    digitalWrite(segC, SEGMENT_ON);
    digitalWrite(segD, SEGMENT_ON);
    digitalWrite(segE, SEGMENT_OFF);
    digitalWrite(segF, SEGMENT_OFF);
    digitalWrite(segG, SEGMENT_ON);
    break;

  case 4:
    digitalWrite(segA, SEGMENT_OFF);
    digitalWrite(segB, SEGMENT_ON);
    digitalWrite(segC, SEGMENT_ON);
    digitalWrite(segD, SEGMENT_OFF);
    digitalWrite(segE, SEGMENT_OFF);
    digitalWrite(segF, SEGMENT_ON);
    digitalWrite(segG, SEGMENT_ON);
    break;

  case 5:
    digitalWrite(segA, SEGMENT_ON);
    digitalWrite(segB, SEGMENT_OFF);
    digitalWrite(segC, SEGMENT_ON);
    digitalWrite(segD, SEGMENT_ON);
    digitalWrite(segE, SEGMENT_OFF);
    digitalWrite(segF, SEGMENT_ON);
    digitalWrite(segG, SEGMENT_ON);
    break;

  case 6:
    digitalWrite(segA, SEGMENT_ON);
    digitalWrite(segB, SEGMENT_OFF);
    digitalWrite(segC, SEGMENT_ON);
    digitalWrite(segD, SEGMENT_ON);
    digitalWrite(segE, SEGMENT_ON);
    digitalWrite(segF, SEGMENT_ON);
    digitalWrite(segG, SEGMENT_ON);
    break;

  case 7:
    digitalWrite(segA, SEGMENT_ON);
    digitalWrite(segB, SEGMENT_ON);
    digitalWrite(segC, SEGMENT_ON);
    digitalWrite(segD, SEGMENT_OFF);
    digitalWrite(segE, SEGMENT_OFF);
    digitalWrite(segF, SEGMENT_OFF);
    digitalWrite(segG, SEGMENT_OFF);
    break;

  case 8:
    digitalWrite(segA, SEGMENT_ON);
    digitalWrite(segB, SEGMENT_ON);
    digitalWrite(segC, SEGMENT_ON);
    digitalWrite(segD, SEGMENT_ON);
    digitalWrite(segE, SEGMENT_ON);
    digitalWrite(segF, SEGMENT_ON);
    digitalWrite(segG, SEGMENT_ON);
    break;

  case 9:
    digitalWrite(segA, SEGMENT_ON);
    digitalWrite(segB, SEGMENT_ON);
    digitalWrite(segC, SEGMENT_ON);
    digitalWrite(segD, SEGMENT_ON);
    digitalWrite(segE, SEGMENT_OFF);
    digitalWrite(segF, SEGMENT_ON);
    digitalWrite(segG, SEGMENT_ON);
    break;

  case 10:
    digitalWrite(segA, SEGMENT_OFF);
    digitalWrite(segB, SEGMENT_OFF);
    digitalWrite(segC, SEGMENT_OFF);
    digitalWrite(segD, SEGMENT_OFF);
    digitalWrite(segE, SEGMENT_OFF);
    digitalWrite(segF, SEGMENT_OFF);
    digitalWrite(segG, SEGMENT_OFF);
    break;
  }
}
27  Community / Exhibition / Gallery / Re: Arduino clock project - 7-segment display & RTC on: February 02, 2014, 07:45:37 pm
Very nice work, I'm trying to build something similar at the moment smiley
28  Using Arduino / Networking, Protocols, and Devices / Re: "Tiny RTC I2C Module" issue on: January 11, 2014, 09:57:50 pm
I'm also having trouble. Have used the adafruit example and tried the code from here http://bildr.org/2011/03/ds1307-arduino/

I am running the sketch with the line uncommented to set the time and get nothing but this

Code:
RTC is NOT running!
2165/165/165 165:165:85
 since midnight 1/1/1970 = 1381621585s = 15990d
 now + 7d + 30s: 2013/10/19 23:46:55

2165/165/165 165:165:85
 since midnight 1/1/1970 = 1381621585s = 15990d
 now + 7d + 30s: 2013/10/19 23:46:55

2165/165/165 165:165:85
 since midnight 1/1/1970 = 1381621585s = 15990d
 now + 7d + 30s: 2013/10/19 23:46:55


Any ideas guys?
29  Using Arduino / Project Guidance / Re: Nicks low power code, modifying for two push buttons on: January 11, 2014, 08:31:59 pm
Thanks Nick. I added a while loop after sending the signals to stall the code while the button is still pressed - works great now.

Thanks again for all your work
30  Using Arduino / Project Guidance / Re: Nicks low power code, modifying for two push buttons on: January 04, 2014, 09:57:33 pm
I'm now trying to integrate the code with some code i have had working to send a IR signal.

Sometimes the led stays high, I guess it could be due to the button press being to long? The orignal code used a serial command so only would run one, I tried adding a delay of 200 after  signal is sent but didn't help.

Not sure if the new code is messing with the interrupts as it seems to disable then re-enable them?

Thanks

Code:
#include <avr/sleep.h>

//const byte LEDA = 13;
const byte LEDB = 12;

#define IRledPin 13
#define NumIRsignals 76

// This is the code I determined works for my Duraflame heater
int IRsignal[] = {
  // ON, OFF (in 10's of microseconds)
  884, 436,
  58, 52,
  58, 162,
  58, 50,
  58, 162,
  58, 162,
  56, 162,
  58, 162,
  58, 52,
  56, 162,
  58, 52,
  58, 160,
  58, 52,
  58, 52,
  58, 50,
  58, 52,
  58, 162,
  58, 160,
  58, 162,
  58, 162,
  56, 162,
  58, 162,
  58, 50,
  60, 50,
  58, 52,
  58, 52,
  58, 50,
  58, 52,
  58, 52,
  56, 52,
  58, 162,
  58, 160,
  58, 162,
  58, 3900,
  882, 216,
  58, 2844,
  882, 216,
  58, 0};



volatile byte wakeUpPin;

void wake_A ()
{
  wakeUpPin = 2;
  // must do this as the pin will probably stay low for a while
  detachInterrupt (0);
  // cancel sleep as a precaution
  sleep_disable();
}  // end of wake_A

void wake_B ()
{
  wakeUpPin = 3;
  // must do this as the pin will probably stay low for a while
  detachInterrupt (1);
  // cancel sleep as a precaution
  sleep_disable();
}  // end of wake_B

void setup ()
{
  pinMode(IRledPin, OUTPUT);
  digitalWrite(IRledPin, LOW);   //Make sure LED starts "off"
  Serial.begin(9600);            //Initialize Serial port
 
 
  digitalWrite (2, HIGH);  // enable pull-up
  digitalWrite (3, HIGH);  // enable pull-up
}  // end of setup

void loop ()
{
  if (wakeUpPin == 2)
  {
    for (int i = 0; i < NumIRsignals; i+=2) {         //Loop through all of the IR timings
      pulseIR(IRsignal[i]*10);              //Flash IR LED at 38khz for the right amount of time
      delayMicroseconds(IRsignal[i+1]*10);  //Then turn it off for the right amount of time
    }
  }

  else if (wakeUpPin == 3)
  {
    pinMode (LEDB, OUTPUT);
    digitalWrite (LEDB, HIGH);
    delay (100);
    digitalWrite (LEDB, LOW);
    delay (100);
    pinMode (LEDB, INPUT);
  }


  // disable ADC
  ADCSRA = 0; 

  set_sleep_mode (SLEEP_MODE_PWR_DOWN); 
  sleep_enable();

  // Do not interrupt before we go to sleep, or the
  // ISR will detach interrupts and we won't wake.
  noInterrupts ();

  // will be called when pin D2 goes low 
  attachInterrupt (0, wake_A, LOW);
  // will be called when pin D3 goes low 
  attachInterrupt (1, wake_B, LOW);




  // turn off brown-out enable in software
  // BODS must be set to one and BODSE must be set to zero within four clock cycles
  MCUCR = bit (BODS) | bit (BODSE);
  // The BODS bit is automatically cleared after three clock cycles
  MCUCR = bit (BODS);

  // We are guaranteed that the sleep_cpu call will be done
  // as the processor executes the next instruction after
  // interrupts are turned on.
  interrupts ();  // one cycle
  sleep_cpu ();   // one cycle


} // end of loop


// This function allows us to PWM the IR LED at about 38khz for the sensor
void pulseIR(long microsecs) {
  // we'll count down from the number of microseconds we are told to wait
 
  cli();  // this turns off any background interrupts
 
  while (microsecs > 0) {
    // 38 kHz is about 13 microseconds high and 13 microseconds low
   digitalWrite(IRledPin, HIGH);  // this takes about 3 microseconds to happen
   delayMicroseconds(10);         // hang out for 10 microseconds, you can also change this to 9 if its not working
   digitalWrite(IRledPin, LOW);   // this also takes about 3 microseconds
   delayMicroseconds(10);         // hang out for 10 microseconds, you can also change this to 9 if its not working
 
   // so 26 microseconds altogether
   microsecs -= 26;
  }
 
  sei();  // this turns them back on
}
Pages: 1 [2] 3 4 ... 40