Show Posts
Pages: 1 ... 64 65 [66] 67 68 ... 114
976  Using Arduino / Programming Questions / Re: DuinOS + Arduino 1.03 + DS18B20 on: February 06, 2013, 11:42:31 am
Quote
I know, Arduino all alone works perfectly with onewire
Have you tried using DuinOS with *only* the DS18B20? Let's make sure that DuinOS and DS18B20 will even work together when there's nothing else that might get in the way.

Pete
977  Using Arduino / Programming Questions / Re: DuinOS + Arduino 1.03 + DS18B20 on: February 06, 2013, 11:01:46 am
Quote
So I know the exact place where the app gets stuck
It doesn't print anything at that point so how can you know that it gets stuck there?
And it would help if you post the code that you are talking about, all of it.
BTW. It would be better if you use Serial.println for debugging messages rather than LCD.print just to be sure that there's no problem with the LCD.

Pete
978  Using Arduino / Programming Questions / Re: DuinOS + Arduino 1.03 + DS18B20 on: February 05, 2013, 05:51:50 pm
Quote
But sprintf is a common C function which was used for decades and everything worked before, even with a float -type.
If you say so, but try this sketch.
Code:
void setup(void)
{
  Serial.begin(9600);
  char oline[32];
  sprintf(oline,"float '%6.2f'",6.231);
  Serial.println(oline);
}

void loop(void){}

Pete
979  Using Arduino / Programming Questions / Re: DuinOS + Arduino 1.03 + DS18B20 on: February 05, 2013, 03:03:43 pm
Code:
sprintf(buffer, "%.2f", num);
AFAIK sprintf can't do floating point conversions so this probably puts a null in the buffer and you end up displaying nothing.
So, what exactly is printed on the Serial monitor?

Pete
980  Using Arduino / Audio / Re: Midi Sustain pedal on: February 04, 2013, 12:27:13 pm
Your code will keep sending a MIDI message as long as the pedal is held down but for a sustain pedal you only need to send a message when the pedal goes down or up. A convenient way to handle this is to read the pedal using an interrupt which is set to trigger on a pedal CHANGE.
Try my code below.
[edit]I've now tested it and the code works on my SY77 if I send Note On/Off or a Program Change message but Control Change doesn't do anything which is presumably a problem with the SY77 not the code.

Pete

Code:
#include <MIDI.h>

/*
 Sustain pedal
 Uses an interrupt to monitor the sustain pedal on pin 2
 and outputs a MIDI Control Change message on pin 1
 Reads a digital input on pin 4, chooses between sustain and sostenuto
*/
 
 
// declare pins.
int toggleSwitch = 4;
int midiOut = 1;
// The pedal MUST be on Arduino pin 2
int togglePedal = 2;

// All this does is set a flag on a pedal transition.
// The loop function looks for the flag.
volatile int transition = 0;
void pedal_transition(void)
{
  transition = 1;
}

void setup(void)
{
  // This will call pedal_transition if the pedal goes up or down
  attachInterrupt(0,pedal_transition,CHANGE);
  pinMode(toggleSwitch, INPUT);
  pinMode(togglePedal, INPUT);
  pinMode(midiOut, OUTPUT);
  MIDI.begin(1);
}

// the code will set cc_pedal to 64 (sustain) or 66 (sostenuto)
// depending on the status of the toggleSwitch
int cc_pedal = 0;

void loop(void)
{
  // There's nothing to do if the transition flag is not set
  if(!transition)return;
  transition = 0;
  if(digitalRead(toggleSwitch)) cc_pedal = 66;
  else cc_pedal = 64;
  // If togglePedal is now high, the pedal is now UP
  // otherwise it is now DOWN
  if(digitalRead(togglePedal)) {
    MIDI.sendControlChange(cc_pedal,0,1);
  } else {
    MIDI.sendControlChange(cc_pedal,127,1);
  }
}
981  Using Arduino / Programming Questions / Re: Energy saving question and RTC DS3234 Alarms on: February 03, 2013, 10:06:43 am
Tack's solution is more complicated than mine. All mine does is read the minutes register, make a decision and go back to sleep.
As I and PaulS have said, the "cost" of waking up and going right back to sleep is negligible. You will not be able to measure the difference in current draw.
What you need to do is write some code and try out the sleep/wake up.

Pete

982  Using Arduino / Programming Questions / Re: DS3234 Alarms on: February 02, 2013, 01:20:46 pm
I've used the DS3231 (I2C similar to DS3234) to wake up every minute and do a task once every ten minutes. The time spent awake when not performing a task is negligible.

Pete
983  Using Arduino / Programming Questions / Re: DS3234 Alarms on: February 02, 2013, 11:34:14 am
I don't think you can make the DS3234 alarm every 15 minutes. You would have to set an alarm to go off every minute and then, when the alarm does go off, read the minutes register to see if it is 0, 15 , 30 or 45.

Pete
984  Using Arduino / Storage / Re: 25LC1024 STORING 16BIT INTEGERS on: January 31, 2013, 03:05:53 pm
The value of 65535 (not 65536?) is a 16-bit word with all ones which is what you get if you read two bytes which have been erased (or deliberately set to 0xFFFF).

Write timing can be critical with EEPROMS. I've had some fun recently getting an I2C 24LC1026 working properly.
The 25lc1024 datasheet has this about writing:
Quote
While the write is in progress, the Status Register may
be read to check the status of the WPEN, WIP, WEL,
BP1 and BP0 bits (Figure 2-6). A read attempt of a
memory array location will not be possible during a
write cycle. When the write cycle is completed, the
write enable latch is reset.

It is possible that it is still writing one byte when you try to write or read another. After the data has been written you'll have to check the status register to be sure that the write has completed.

Pete
985  Using Arduino / Storage / Re: 25LC1024 STORING 16BIT INTEGERS on: January 31, 2013, 02:36:55 pm
I'm pretty sure you have to call SPI.begin before doing anything else. Otherwise your setup of bitorder etc. will be overridden by whatever default is set by SPI.begin.

Pete
986  Using Arduino / Storage / Re: 25LC1024 STORING 16BIT INTEGERS on: January 30, 2013, 11:12:01 am
I don't think you are reading or writing them correctly.
Try writing the two bytes like this:
Code:
  digitalWrite(SS, LOW);
  SPI.transfer(WRITE); // write instruction
 
  // Write low byte first
  SPI.transfer((lowaddress >> 16) & 255);
  SPI.transfer((lowaddress >> 8) & 255);
  SPI.transfer(lowaddress & 255);
  SPI.transfer(low);
  SPI.transfer(high);
 
  digitalWrite(SS, HIGH);

and do the same thing with reading them.

Pete
987  Using Arduino / General Electronics / Re: Connecting Canon T3 to Arduiono. on: January 30, 2013, 10:48:37 am
The first thing I'd try is putting the two very close together, preferably with something around them to shield the receiver from ambient radiation but I doubt that it will help. The receiver is probably not seeing enough IR to drive the output hard enough to fire the camera. You could add a transistor on the output to amplify it.
But an optoisolator would work better. It might still require a transistor for the output but it would be more reliable than separate Tx/Rx.

Pete
988  Using Arduino / Programming Questions / Re: GPS strings on: January 29, 2013, 10:58:19 pm
Does your GPS output at 4800 baud?
Mine outputs at 9600.

Pete
989  Using Arduino / Storage / Re: 25LC1024 STORING 16BIT INTEGERS on: January 29, 2013, 01:47:06 pm
When it always reads everything as 255 it usually indicates a wiring error.
But, if for any reason it doesn't write the value into the EEPROM, then you'll get 255 back anyway because that is the initial state of the erased EEPROM.

Pete
990  Using Arduino / Storage / Re: 25LC1024 STORING 16BIT INTEGERS on: January 29, 2013, 10:37:00 am
What is wrong?

Pete
Pages: 1 ... 64 65 [66] 67 68 ... 114