Recent Posts

Pages: [1] 2 3 ... 10
Please post the transmitter code, and examples of the data that you are receiving.
Assuming you are using the sketch in post #8.

Your problem maybe your:

- remote is not compatible with your IR receiver.
- remote is not NEC compatible
- wiring is in error
- receiver

Two possibilities to consider: CMOS hex inverter driver or adding a coil across the piezo to increase the voltage.

Inverter circuit:

Coil circuit.
Please post the complete code.

I can see at least 3 conditions even in that unhelpful fragment. Which one is "this condition"?

here is the full code
Code: [Select]

#define GREEN 3
#define BLUE 6
#define WHITE 10
#define RED 9
#define YELLOW 11
#define RED 5

const int ledPin = 3;
int ledState = LOW;
unsigned long previousMillis = 0;
const long interval = 1000;

byte statusLed    = 13;
byte sensorInterrupt = 0;
byte sensorPin       = 2;
float calibrationFactor = 4.5;
volatile byte pulseCount;  
float flowRate;
unsigned int flowMilliLitres;
unsigned long totalMilliLitres;
unsigned long oldTime;

void setup()
  pinMode(statusLed, OUTPUT);
  digitalWrite(statusLed, HIGH);
  pinMode(sensorPin, INPUT);
  digitalWrite(sensorPin, HIGH);
  pinMode(ledPin, OUTPUT);





  pulseCount        = 0;
  flowRate          = 0.0;
  flowMilliLitres   = 0;
  totalMilliLitres  = 0;
  oldTime           = 0;

  attachInterrupt(sensorInterrupt, pulseCounter, FALLING);

void loop()
   if((millis() - oldTime) > 1000)
    flowRate = ((1000.0 / (millis() - oldTime)) * pulseCount) / calibrationFactor;
    oldTime = millis();
    flowMilliLitres = (flowRate / 60) * 1000;
    totalMilliLitres += flowMilliLitres;
    if (ledState == LOW &&((flowRate < 0.01)) (digitalWrite(GREEN,HIGH));
    ledState = HIGH;
    else digitalWrite (GREEN,LOW);

     if (flowRate >= 4.00) digitalWrite(BLUE,HIGH);
    else digitalWrite (BLUE,LOW);

     if (flowRate >= 12.01) digitalWrite(WHITE,HIGH);
    else digitalWrite (WHITE,LOW);

     if (flowRate >= 22.1) digitalWrite(RED,HIGH);
    else digitalWrite (RED,LOW);

     if (flowRate >= 34.1) digitalWrite(YELLOW,HIGH);
    else digitalWrite (YELLOW,LOW);
    unsigned int frac;
    Serial.print("Flussometro: ");

    Serial.print("Quantita': ");        

    pulseCount = 0;
    attachInterrupt(sensorInterrupt, pulseCounter, FALLING);

void pulseCounter()

the condition you can see in the void loop .
I just need to insert a double condition with double 'then' or 'do' to make a led blink when the flow is <0.01 (which will be a very good sign instead of just being lighted up ) , blinking is more notable
so my attempt was :
Code: [Select]

if (ledState == LOW &&((flowRate < 0.01)) (digitalWrite(GREEN,HIGH));
    ledState = HIGH;
    else digitalWrite (GREEN,LOW);

which did not work .. error in compiling /making order
Error message : expression cannot be used as a function, lighting up in red the '...If ..' string

Hardware / Sensor Sharp GP2Y0A21 no funci...
Last post by ziceck - Today at 03:08 am
Estoy utilizando un puente H para controlar dos motores, y un sensor infrarrojo GP2Y0A21 (para detectar si un objeto está cerca o lejos) éste funciona bien si lo pruebo solo, pero el problema está en que al tenerlo conectado al mismo tiempo que el puente H arroja mediciones incorrectas ya que siempre detecta un objeto.
Al parecer el error está ocasionado por qué el sensor comparte el mismo pin de voltaje y de tierra que usa el puente, por ahora lo he solucionado conectando el sensor al otro pin de tierra del arduino y a otro pin de 3.5 de voltaje, pero me gustaría saber como podrían compartir los mismos pines sin que obtenga mediciones incorrectas.
Generale / Re: Flussometro e accensione l...
Last post by Sighline - Today at 03:03 am
sicuramente sara' piu' facile usare un led lampeggiante . Ma volevo arrivarci con il code
Generale / Re: Flussometro e accensione l...
Last post by Sighline - Today at 02:56 am
Non semplice, devi usare una variabile di stato, a vero farai eseguire (in base ad un altro if(stato==vero) la parte di codice che accende/spegne il led
Forse più semplice usare un led che già da solo lampeggia. non costano molto.
Ho provato questo ma da' l'errore di esecuzione
if (ledState == LOW &&((flowRate < 0.01)) (digitalWrite(GREEN,HIGH));
    ledState = HIGH;
    else digitalWrite (GREEN,LOW);
Sensors / Which pin is "output"?
Last post by SeniorGeezer - Today at 02:55 am

Suppose I want to read Green component of a color sample using the TCS34725 RGB Color Sensor ... see attachment.

It is my understanding that I need to take the SDA and SCL pins LOW in order to read from the sensor.

My question is ... from which pins do I take the output?



Displays / Re: 3.5 inch TFT display for A...
Last post by muralysunam - Today at 02:51 am
The SD card is mapped correctly to the Mega's hardware SPI pins.    CS is digital#53 i.e. the default SS pin.

You can try any SD.h examples that you like.    You do not need to worry about the TFT.

The SD might work but it will be very unreliable.

ALL these red Mcufriend 2560 shields rely on resistor packs to provide safe signals from the 5V Mega to the 3.3V hardware.     It works fine with the TFT and XPT2046.    The resistor pack values are too big for the SD.

If you manage to get any SD apps to work,   please let us know.


Thanks for fast reply.

So it is normal in these type of shields right?

When I use Etherenet shield it works fine(with this arduino mega).

I can't even show one bmp file(One bmp file takes approx 300KB which is too big for arduino mega). Is there any other method for accessing SD card with these shield(or showing 3 pictures of this size.)? 

Thanks a lot...
My Arduino project is a level indicator that uses a Piezo transducer.
I've used the "tone" function to manipulate the sound to raise the pitch when the desired level is reached.
With the 'tone' function I can very precisely control the pitch and speed of the speaker.
However, the project runs from a Lipo battery, and even with 5 volts, the transducers i've tried don't get very loud.

I wish to limit my projects size and complexity as much as possible.
This is why I'd rather not use a boost converter simply for the piezo part of the circuit.

Differential drive:​

I found a solution online where you could use 2 MCU pins (instead of 1 pin & ground) to effectively double the output!
This works!
As long as you turn on one pin and the other off simultaneously the effect is a doubling of the piezo voltage.
(I think that the 2nd pin in the (LOW) state is also able to source some current, however it does not work if I try to replace the ground with an MCU GPIO pin)
This is very simple to do, I used boolean logic in my demo sketch:
digitalWrite(Pin_1, ringState);
digitalWrite(Pin_2, !ringState);

The problem with software differential drive: the tone() function compatibility.

The Tone function makes the frequency voicings I require possible (and simplifies the sketch considerably from direct control)
The Tone function takes control of a MCU timer, and I'm pretty certain you cannot have 2 'tone' functions running at once
(i.e. a "tone()" and one "!Tone()" to drive the other pin)
I would have to litter my sketch with" digitalWrite(Pin_2, !ringState); calls to try to switch the differential pin in time, but I don't think that even this would work.
I'm open to code suggestions if you have an idea that might work.


What type of inverting logic would I need that would provide Vcc to the other side of the Piezo when the MCU driver pin was LOW?
I know that you can create simple NOT logic from a single NPN transistor:

I can't just replace the MCU pin for the push button and the Piezo for the LED, but is there a way to change this around to make it work?
Or, should I use a different inverting component?
Pages: [1] 2 3 ... 10