Recent Posts

Pages: 1 ... 8 9 [10]
On the same lines of your program UKHeliBob ,I wrote this program for password , the LCD successfully print "Enter password",confirming that we are in the VOID SETPASSWORD loop.
However,when in this loop, i press enter, the PrintKey case is never performed, rather it prints the ENTER Key value.

What changes should i make?
Please refer the Void SetPassword loop at the very end of program.

Regarding what PaulS pointed out, I know that
If there is data to be read from the keyboard object, the body of the if statement will be executed. If not, the else if statement will be evaluated.
I agree it is foolish of me,but i really don't want any possible combination left untried. :)

The Code:
Code: [Select]
#include <LiquidCrystal.h>
#include <PS2Keyboard.h>

#define KeyRead 0
#define PrintKey 1

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 13, 14, 15, 16, 17);

const int DataPin = 2;
const int IRQpin =  3;

PS2Keyboard keyboard;

char KbChars;
char array[50];
char KeyStore[6];
char inByte;
int i=0;

void setup() {

  lcd.begin(16, 2);
  keyboard.begin(DataPin, IRQpin);
  lcd.setCursor(0, 0);
  lcd.print("Input Message:");

void loop() {
   if (keyboard.available()) {;
  if (KbChars == PS2_ESC)
  if (KbChars == PS2_TAB) {
      lcd.setCursor(0, 0);
      lcd.print("Ciphered Text:");
      lcd.setCursor(0, 1);

  if(KbChars == PS2_PAGEUP){

void rot13() {

         for (int i = 0; i <= 50; ++i) { 
            inByte = array[i];
       if (!inByte) return; //end of string reached
        if (inByte >= 'A' && inByte <= 'M')
            inByte +=13;
        else if (inByte >= 'a' && inByte <= 'm')
            inByte +=13;
        else if (inByte >= 'N' && inByte <= 'Z')
            inByte -=13;
        else if (inByte >= 'n' && inByte <= 'z')
            inByte -=13;
        array[i] = inByte;
void SetPassword(){
   static int  state = KeyRead;  // initial state is 1, the "idle" state.
   switch (state)
    case KeyRead:
    if (keyboard.available)    //user has pressed a key
        char KeyFromKeybd =;    //read the user input
        if (KbChars == PS2_ENTER)      //was it ENTER ?
          state = PrintKey;          //if it was then change state
          KeyStore[i] = KeyFromKeybd;        //otherwise put the user input into the array
          KeyStore[i] = '\0';           //terminate the array
        lcd.print("Set Password:");
       case PrintKey:      //print what the user input
      lcd.print("Password is..");
      i = 0;                   //reset the index to the array
      state = KeyRead;
Programming Questions / Re: Arduino Update in MySQL
Last post by PaulS - Today at 03:33 pm
this code I would like that when is HIGH update the database to 1 and when it is LOW update to 0.
When what is HIGH? Or LOW?

Code: [Select]
char query_4[80];

   sprintf(query_4, "update minhacas_a.usuario1 SET position = '%d' where id_rele = 1;", somethingThatIsHIGHOrLOW);
Français / Re: Besoin d'aide (ruban led p...
Last post by mikafed26 - Today at 03:33 pm
merci à tous pour vos réactions, je vais essayer deux trois solutions.

pour répondre a la question infobarquee, je veut pouvoir l'allumer et l'éteindre quand j'en ai envie enfait, alors oui ça ferait la même chose qu'un interrupteur mais pourquoi faire simple quand on peut faire compliqué ^^
quel est l'avantage d'un détecteur de distance?

merci erwin38 pour ton lien mais j'y suis deja passé dessus sans avoir pu resoudre mon probleme :
Megatopic / Re: Modulo Wi-Fi ESP8266
Last post by SmallG - Today at 03:32 pm
va' collegato cosi'

Ottimo, è possibile sapere cosa comporta/a cosa serve quel filo che va sia al ground che verso nient'altro? Perché non basta il solo ground?

Sto provando a collegarlo anche in fisico così:

È giusto il pinout che dici, ma l'hai collegato al contrario, mettendo 5V su GND e GND sull'input!
Non so, forse è sbagliato il componente che ho importato su fritzing, perché andando lì col filo mi segna IN in alto.

Non è che perché devi scambiare pochi dati puoi collegarlo a caso ;). Devi sistemare tutte le cose che ti abbiamo fatto notare. Per i condensatori prova pure senza, ma ordinali e appena possibile aggiungili, questo voleva essere il senso del messaggio precedente.

Per il codice usa la libreria e guarda i suoi esempi, coprono molti dei casi di utilizzo.
Certo, mi sono spiegato male. Intendevo che volevo lasciare i condensatori/dioidi anche se dici che potrebbero non servire, proprio per evitare che perda in stabilità.

Sto procedendo con la 1 perché di questa ho tutto, mentre devo lasciare per ora da parte la soluzione 2 in quanto mi mancano gli ultimi componenti che hai citato, e come giustamente mi confermi, meglio evitare collegamenti a caso se mancano pezzi. :D
Sicuramente li ordiniamo se la soluzione 1 non offre i risultati sperati.

Grazie ancora!
Programming Questions / Re: boolean array
Last post by medeloualidi - Today at 03:32 pm
UKHeliBob yes exactly that what I want to do,
Deutsch / Re: Arduino Konstantstromquell...
Last post by DrDiettrich - Today at 03:32 pm
Dann tut es jetzt also, und die Spannungsdifferenz zwischen -Vin und Arduino Gnd ist 0V?

Wenn's ganz dumm geht, dann hast Du den PWM-Ausgang geschlachtet - ggf. anderen Pin ausprobieren.
so below i attached what i have now, put the resistors back in series.. also attached my code based on putting together many other things from this forum that i had found on debouncing and state changes. on a side note my Arduino is now not being read by my computer either... this is a pain in the a$# project .. lol one thing leads to another.
Project Guidance / Re: pullup LED
Last post by Tinkerspy - Today at 03:32 pm
I think this should work. Both buttons must be pressed for the led to come on. The buttons works as toggles in conjunction with the 'bit' machine. The controller checks the bits and switches the led on/off according to their state.

Code: [Select]

#include <Automaton.h>

Atm_button button1, button2;
Atm_controller ctl;
Atm_bit bit1, bit2;
Atm_led led;
Appliance app;

void setup() {
  app.component( led.begin( 4 ) );
  .IF( bit1 ).AND( bit2 )
  .onChange( true, led, led.EVT_ON )
  .onChange( false, led, led.EVT_OFF )
  app.component( bit1.begin() );
  app.component( bit2.begin() );
  app.component( button1.begin( 2 ).onPress( bit1, bit1.EVT_TOGGLE ) );
  app.component( button2.begin( 3 ).onPress( bit2, bit2.EVT_TOGGLE ) );

void loop() {;
Deutsch / Re: kann man das schöner schre...
Last post by Eisebaer - Today at 03:32 pm

Code: [Select]
nThrottleIn=nThrottleIn<=920 ? 900 : (nThrottleIn>=2080 ? 2100:nThrottleIn)

ich liebe solche dinge, um kollegen in der firma zu beeindrucken, aber ein halbes jahr später ist es dann schwer, den eigenen code nachzuvollziehen.

irgendwie begeht man auch den fehler, zu glauben, daß kürzerer quellcode das programm schneller macht.

für mich ist das eher ein fall für eine eigene funktion. so bleibt's übersichtlich.

gruß stefan

PS.: aber ist ja richtig, die frage war "schöner", also insofern war theseus' lösung die bisher schönste...
Programming Questions / Re: Question about Strings!
Last post by xenoneng - Today at 03:32 pm
Thanks a lot. My problem solved with your help. :-)
Pages: 1 ... 8 9 [10]

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131