Recent Posts

Pages: 1 2 [3] 4 5 ... 10
21
You can't power a device using a logic level converter or a voltage divider. Use a regulated 3.3V power supply of some sort. 2 X AA batteries will work too.

Better yet use a 3.3 V pro mini, or power a 5 V pro mini with 3 V on Vcc, and make all connections direct
22
Hello,

I have a solenoid whcih is just switching  between on and off without the control pin being connected to the microcontroller.

I have attached the picture of the driver circuit of the solenoid .

The wires from the left most side ( vdd,gnd,control) connect on to a PCB. The Vdd and Gnd go to power button  https://www.adafruit.com/product/1400

Without connecting the microcontroller, if I press the power button, the solenoid switches on and off.

Can any one please explain why the solenoid opens and closses without the microcontroller?

Thank you!
23
Project Guidance / Re: AD9854 DDS Help
Last post by ke4est - Today at 05:13 pm
If anyone would like a copy of my code I will be more than happy to provide it, there are a few tweaks work in progress at the moment however please feel free to ask any questions.

Cheers

Rob.
Would love to see your code Rob, as I am working on something similar.
24
Generale / Re: CONTROLLO STATO ARDUINO
Last post by docdoc - Today at 05:13 pm
Ciao @docdoc, hai degli esempi ?  Mi interessa la tua lib.
La libreria l'avevo scritta per me quando stavo sviluppando un robottino, ti riporto sotto una porzione di codice "demo" che usai per testare la libreria (gestisce solamente un pulsante e 2 led) con la quale dovresti riuscire a capire come usarla. Se avete anche commenti o consigli, scrivetemi.

Appena possibile devo decidermi a mettere questa libreria (ed un altro paio) anche su GitHub, dopo qualche revisione che ho già in mente...

Code: [Select]

#include <SimpleTimer.h>

#include <FiniteState.h>
// ***********************************************
// MACCHINA A STATI FINITI
// ***********************************************
FiniteState fsm;
// Stati del robot
#define S_START 1
#define S_FLASH 2
#define S_STEADY 3
#define S_LED2 4
// Condizioni del robot
#define C_BUTTON 0
#define C_LED2_OFF 1
// Action del robot
#define A_LED_OFF 0
#define A_LED_ON 1
#define A_FLASH 2
#define A_LED2_ON 3

// ***********************************************
// COSTANTI E MACRO
// ***********************************************
// Pin
#define LED 5
#define LED2 2
#define BUTTON 7

// ***********************************************
// VARIABILI
// ***********************************************
int blink = 0;
int led = LOW;

// ***********************************************
// OGGETTI GLOBALI
// ***********************************************
const int BREAK = fsm.BREAK;
const int NONE = fsm.NONE;
// the timer object
SimpleTimer timer;
int tmrBlink = -1;
int tmrSingle = -1;

// ***********************************************
void setup() { 
  Serial.begin(115200);
  delay(500);

  // Definizione degli stati
  // Stato START, evento BUTTON, azione FLASH, parametro 200, nuovo stato FLASH
  fsm.Write(S_START, C_BUTTON, A_FLASH, 200, S_FLASH);
  // Stato FLASH, evento BUTTON, azione LED_ON, parametro 0, nuovo stato STEADY
  fsm.Write(S_FLASH, C_BUTTON, A_LED_ON, 0, S_STEADY);
  // Stato STEADY, evento BUTTON, azione LED2_ON, parametro 5000, nuovo stato LED2
  fsm.Write(S_STEADY, C_BUTTON, A_LED2_ON, 5000, S_LED2);
  // Stato LED2, evento LED2_OFF, azione LED_OFF, parametro 0, nuovo stato START
  fsm.Write(S_LED2, C_LED2_OFF, A_LED_OFF, 0, S_START);
  // Stato LED2, evento BUTTON, azione LED_OFF, parametro 0, nuovo stato HALT
  fsm.Write(S_LED2, C_BUTTON, A_LED_OFF, 0, fsm.HALT);
 
  // Inizia dal primo stato
  fsm.Set(S_START);
  Serial.print("Stato iniziale=");
  Serial.println(fsm.State);
 
  pinMode(LED, OUTPUT); 
  pinMode(LED2, OUTPUT); 
  pinMode(BUTTON, INPUT);
 
}

// ***********************************************
void loop() {
  // Ciclo di esecuzione degli stati
  while ( fsm.State != fsm.HALT && fsm.Next() != BREAK ) {
    // Verifica se è presente una condizione per cambiare stato
    if ( TestCondition() ) {
      DoAction();
      fsm.SetNext();
      Serial.print("STATO: ");
      Serial.println(fsm.State);
      break;
    }
  }

  // Altre azioni
  DoWork();
 
}

boolean TestCondition() {
  static int val0 = 0;
  int btn;
 
  switch ( fsm.Condition() ) {
    case C_BUTTON:
      btn = digitalRead(BUTTON);
      if ((btn == HIGH) && (val0 == LOW)) {
        val0 = btn;
        delay(200);
        return true;
      }
      val0 = btn;
      return false;

    case C_LED2_OFF:
        return (digitalRead(LED2) == LOW);
     
  }
  return false;
}

void DoAction() {
  switch ( fsm.Action() ) {
   
    case A_LED_OFF:
      blink = 0;
      digitalWrite(LED, LOW);
      return;
     
    case A_LED_ON:
      if ( tmrBlink != -1 ) {
        timer.deleteTimer(tmrBlink);
        tmrBlink = -1;
      }
      digitalWrite(LED, HIGH);
      digitalWrite(LED2, LOW);
      return;
     
    case A_FLASH:
      blink = fsm.Param();
      digitalWrite(LED, HIGH);
      digitalWrite(LED2, LOW);
      if ( tmrSingle != -1 ) {
        timer.deleteTimer(tmrSingle);
        tmrSingle = -1;
      }
      tmrBlink = timer.setInterval(blink, BlinkLed);
      return;
     
    case A_LED2_ON:
      blink = fsm.Param();
      digitalWrite(LED, LOW);
      digitalWrite(LED2, HIGH);
      if ( tmrBlink != -1 ) {
        timer.deleteTimer(tmrBlink);
        tmrBlink = -1;
      }
      tmrSingle = timer.setTimeout(blink, Led2Off);
      return;
  }
  return;
}

void DoWork() {
  timer.run();
}

void BlinkLed() {
  digitalWrite(LED, !digitalRead(LED));
}

void Led2Off() {
  digitalWrite(LED2, LOW);
}



EDIT: scusa, anche se al 95% è esatto, credo che questo sia un codice non allineato e non credo compili correttamente, stasera da casa sistemo e mando la versione corretta ma intanto puoi da qui già capire la filosofia!!
25
Or, change it to:   (cell * 100) / 22

In integer math, 100 / 22 = 4, and 4 * 22 = 88.

Using the equation above, 22 * 100 = 2200, and 2200 / 22 = 100

Regards,
Ray L.
26
Project Guidance / Re: RF signal reception
Last post by alex_poupakis - Today at 05:10 pm
Thank you for the reply!

Will that be sufficient for long range (~30km) communication?
27
Project Guidance / Re: Problems in AP mode EPS-12
Last post by PieterP - Today at 05:08 pm
Could have something to do with the hardware RX buffer being only 128 bytes long. I didn't look at your code in detail, but it's probably too slow. Try to read the buffer as fast as possible, before it's full.

Pieter
28
Software / Re: Varios procesos. ¿Cómo?
Last post by grekos - Today at 05:07 pm
tengo un caso parecido y no me sirve esto, creo que la única solución sería  el multithreading (que no es posible con arduino). Imaginemos que en el void loop tenemos 8 leds que se encienden uno detrás de otro...y una interrupción cada 10 segundos con un sensor de temperatura dht22 que tarda x segundos en hacer la lectura...cada vez que haga la lectura del sensor, la iluminación de esos leds se parará por el tiempo que tarda este sensor en hacer dicha lectura. El caso real es con un dht22, un shift register 75hc595n y dos displays de 7 segmentos y dos digitos cada uno.
29
Project Guidance / Re: RF signal reception
Last post by jremington - Today at 05:05 pm
By far the easiest route is to use the NRX2 and follow the manufacturer recommendations.
30
Nederlands / Re: foutmelding
Last post by PieterP - Today at 05:04 pm
Code: [Select]

if (buttonstate == HIGH) (
digitalWrite(ledpin, HIGH)               (hierover gaat de foutmelding)
)
(
digitalWrite(ledpin, LOW)
    )
}

Rond de body van een if-statement staan accolades {} (e. curly braces/brackets). En achter elke lijn code komt een puntkomma ; .
Je mist volgens mij ook een else-clause.

Code: [Select]

if (buttonstate == HIGH) {
  digitalWrite(ledpin, HIGH);
} else {
  digitalWrite(ledpin, LOW);
}


Dat alles terzijde, het is een vrij belachelijk stukje code, dat eenvoudig vervangen kan worden door:
Code: [Select]
digitalWrite(ledpin, buttonstate);


Jammer genoeg is de kwaliteit van vele YouTube-video's over Arduino niet erg hoog ...

Pieter
Pages: 1 2 [3] 4 5 ... 10