Show Posts
Pages: [1] 2 3
1  International / Nederlands / Op zoek naar een LCD afdek plaatje on: September 14, 2014, 05:29:33 am
Dag mensen,

Ik ben op zoek naar een afdekplaatje of houder voor een standaard 2x16 tekens LCD schermpje. Bijvoorbeeld: http://www.hobbytronics.co.uk/lcd-bezel-16x2 maar dan voor minder dan 8 euro. Op de Nederlandse webshops kan ik niks vinden wat in de richting komt.
2  Using Arduino / Project Guidance / Re: Using a keyswitch to select a function (and announce the change..) on: June 13, 2014, 03:06:46 pm
Thanks Xpendable, I'm gonna work in this!
3  International / Nederlands / Re: Sleutelschakelaar gebruik on: June 13, 2014, 02:38:06 pm
Oh sorry ik was blijkbaar niet duidelijk! Het aansluiten is geen probleem, ik heb 3 digitale pinnen en ik kan checken op welke stand hij staat (100,010,001)

Ik heb echter drie functies die moeten draaien Func1(), Func2(), Func3(). Dmv een state case machine kan ik dat al doen.

Quote
State(mode)
case 1:
Func1();
break;
case 2:
Func2();
enz

Maar wat ik wil dat bij een verandering van de state, eenmalig een bericht op mn lcd scherm komt (of een Serial.print(mode))).
4  Using Arduino / Project Guidance / Re: Using a keyswitch to select a function (and announce the change..) on: June 13, 2014, 02:34:35 pm
Difficult to post the code as there isn't yet. What I want is a single function to be executed when the mode changes.
5  Using Arduino / Project Guidance / Using a keyswitch to select a function (and announce the change..) on: June 13, 2014, 01:51:38 pm
Hi all,

For my new project I have bought a keyswitch with 3 positions which I want to use to control my project. At the moment my idea is to use a switch case construction so that I can switch between three functions I use. However my approach doesn't let me really handle the switch.

For example I would like to send a message to a LCD screen when I switch from one case to another.

Code:
switch(mode) {
 case 2:
 Menu2();
 break;
 case 3:
 Menu1();
 break;
 default:
 ReadTag();
 break;
}

Where mode is determined by the position of the switch.

How would you do this?
6  International / Nederlands / Sleutelschakelaar gebruik on: June 13, 2014, 01:19:44 pm
Voor mijn project heb ik een sleutelschakelaar gekocht met drie standen (links, midden, rechts) die ik wil integreren.

De bedoeling is dat het "hoofd" programma draait als de sleutel in het midden staat en dat ik in dit geval een menu wil openen als ik de sleutel naar links draai en een ander menu als de sleutel naar rechts gaat.

Ik heb mijn hoofd hierover gebroken en ik dacht zelf aan een switch case constructie maar ik ben er nog niet uit.
7  Using Arduino / Networking, Protocols, and Devices / Re: EthernetShield (without UTP cable inserted) on: November 17, 2013, 03:57:14 am
It does, at least mine does. It takes over a minute for the dhcp request to time out and return the fail.

I've timed it and it takes well over a minute (1 min 56) before it times out. Is there a way to speed this up?
8  Using Arduino / Networking, Protocols, and Devices / EthernetShield (without UTP cable inserted) on: November 16, 2013, 11:14:52 am
Hi,

Below is my setup code:
Code:
void setup()
{
  // start the Ethernet connection:
  if (Ethernet.begin(mac) == 0)
  {
    Serial.println("Failed to configure Ethernet using DHCP");

    while(true);
  }
  Udp.begin(localPort);
  Serial.flush();
  Serial.begin(9600);
  Serial1.flush();
  Serial1.begin(9600);
  RFID.flush();
  RFID.begin(9600);


  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);


  pinMode(53, OUTPUT);

  SD.begin(4);
  UpdateSaldo();


}

It works with the UTP cable connected; it connects to the DHCP server gets an IP address etc and continues with the program. However when the UTP cable is disconnected or the router is offline it will not do anything (I would figure that it then would print to the serialport "Failed to configure.." etc. Why is this not the case?
9  Using Arduino / Programming Questions / Re: Reading an Internet String on: July 24, 2013, 07:38:08 am
Serial ouput:

Code:
<0>10</0>
<1>25</1>
<2>0</2>
<3>0</3>
<0></0>
10  Using Arduino / Programming Questions / Re: Reading an Internet String on: July 24, 2013, 07:33:39 am
Never mind, I read over the obvious mistake. http_response is ofcourse the parsed version of the orginal so calling it again will detect nothing.
11  Using Arduino / Programming Questions / Reading an Internet String on: July 24, 2013, 07:30:35 am
Hi guys,

I have the following code:

Code:
void antwoord()
{


  for (int t=0; t <= 4; t++){

    String user = String(t);
    String ein = "<";
    String zwei = user;
    String drei = ">";
    String xxx = "/";
    String response = ein + zwei + drei;
    String endresponse = ein + xxx + zwei  + drei;
   
    Serial.print(response);
    Serial.println(endresponse);
    Serial.println(http_response);

    if((http_response.indexOf(response) > -1 )&&(http_response.indexOf(endresponse) > -1 )){
      // We check if the <arduino></arduino> are there.
      response_start = http_response.indexOf(response)+3;
      // Where it begins, the 9 is the length of ' <arduino> ',
      // since we dont want it to appear in the response.
      response_end = http_response.indexOf(endresponse);
      // Where it ends
      http_response = http_response.substring(response_start,response_end);
      // We keep only the response of the website
      Serial.println("Website response : ");
      Serial.println(http_response);
      Serial.println();
      delay(100);

      int Plus = http_response.toInt();
      int Saldo = EEPROM.read(t);
      int NewSaldo = Saldo + Plus;
      Serial.println("New Saldo: ");
      Serial.println(NewSaldo);
      Plus = 0;
      Saldo = 0;
      NewSaldo = 0;
      http_response = 0;

    }
    else {
      Serial.println("No response detected...");
      Serial.println();
    }

  }

It is supposed to take the value's between <t> and </t> and use it to add its content to the integer Saldo. This works for the first run (t=0) but after that t=1,2,3 give me no response detected.

Not sure how this happens.
12  International / Nederlands / Re: TowiTek RFID Reader on: July 17, 2013, 04:24:53 pm
Even een bump met een nieuwe vraag, is het mogelijk om de hardware seriele poorten van de Mega te gebruiken met inverse signalen?
13  International / Nederlands / Re: TowiTek RFID Reader on: February 16, 2013, 12:26:34 pm
Quote
String content = "";
  char character;
    int tester=0;
    String cont2=0;
   
  while(RFIDReader.available()) {
      character = RFIDReader.read();
      tester = (character + '255');
      content.concat(tester);
     
  }

  if (content != "") {
    Serial.println(content);
    cont2.concat(content);
   Serial.println(cont2);

Ik maak er dmv er 255 bij op te tellen een ansi code
14  International / Nederlands / Re: Verbeteringen, Ethercard, RFID lezer. on: February 16, 2013, 09:58:23 am
Code:
void loop()
{
  ether.packetLoop(ether.packetReceive());



  String content = "";
  char character;
    int tester=0;
    String cont2=0;
    
  while(RFIDReader.available()) {
      character = RFIDReader.read();
      tester = (character + '255');
      content.concat(tester);
      
  }

  if (content != "") {
    Serial.println(content);
    cont2.concat(content);
   Serial.println(cont2);
   Beep(100);
   delay(50);
   Beep(100);

  

      if (millis() > timer + REQUEST_RATE) {
      timer = millis();
      Serial.println("\n>>> REQ");
      
      char RFT[30];
      String xcode = String(cont2);
      xcode.toCharArray(RFT,30);

      foundPatternState=0;// Reset state machine
      ether.persistTcpConnection(true);// enable persist, so that the callback is called for each received packet.
      
      ether.browseUrl(PSTR("/dev_frizz.php?tag="), RFT, website, browseUrlCallback);
 delay(1000);
 Serial.println("Ready");
      



    }
    }
  }



// Magical stuff below

void ReadSerial(String &ReadTagString)
{
  int bytesread = 0;
  int  val = 0;
  char code[10];
  String TagCode="";

  if(RFIDReader.available() > 0) {          // If data available from reader
    if((val = RFIDReader.read()) == 10) {   // Check for header
      bytesread = 0;
      while(bytesread<10) {                 // Read 10 digit code
        if( RFIDReader.available() > 0) {
          val = RFIDReader.read();
          if((val == 10)||(val == 13)) {   // If header or stop bytes before the 10 digit reading
            break;                         // Stop reading
          }
          code[bytesread] = val;           // Add the digit          
          bytesread++;                     // Ready to read next digit  
        }
      }
      if(bytesread == 10) {                // If 10 digit read is complete

        for(int x=0;x<10;x++)              //Copy the Chars to a String
        {
          TagCode += code[x];
        }
        ReadTagString = TagCode;          //Update the caller
        while(RFIDReader.available() > 0) //Burn off any characters still in the buffer
        {
          RFIDReader.read();
        }

      }
      bytesread = 0;
      DisplayTAG = 0;

    }
  }
}


void Beep(int x)
{

digitalWrite(7, HIGH);
delay(x);
digitalWrite(7, LOW);
}

void Red(int x)
{
  digitalWrite(9, HIGH);
  delay(x);
  digitalWrite(9, LOW);
}

void Green(int x)
{
  digitalWrite(3, HIGH);
  delay(x);
  digitalWrite(3, LOW);
}

void Blue(int x)
{
  digitalWrite(10, HIGH);
  delay(x);
  digitalWrite(10, LOW);
}

void Relais(int x)
{
  digitalWrite(6, HIGH);
  delay(x);
  digitalWrite(6, LOW);
}

void Consumption()
{
  digitalWrite(6, HIGH); // Relais aan
  digitalWrite(3, HIGH); // Groen aan
  digitalWrite(7, HIGH); // Beep aan
  delay(50);
  digitalWrite(7, LOW); // Beep uit
  delay(50);
  digitalWrite(6, LOW); // RELAIS uit
  digitalWrite(7, HIGH);
  delay(50);
  digitalWrite(7, LOW);
  delay(50);
  digitalWrite(7, HIGH);
  delay(50);
  digitalWrite(7, LOW);
  delay(1000);
  digitalWrite(3, LOW);
 delay(200);
}

void GeenSaldo()
{

  digitalWrite(9, HIGH); // Groen aan
  digitalWrite(7, HIGH); // Beep aan
  delay(100);
  digitalWrite(7, LOW); // Beep uit
  delay(100);
  digitalWrite(7, HIGH);
  delay(100);
  digitalWrite(7, LOW);
  delay(1500);
  digitalWrite(9, LOW);
}

void Pauze(){
  digitalWrite(10, HIGH);
  delay(2000);
  digitalWrite(10, LOW);
  Beep(10);
}
15  International / Nederlands / Re: Verbeteringen, Ethercard, RFID lezer. on: February 16, 2013, 09:58:07 am
Code:
#include <SoftwareSerial.h>
#include <EtherCard.h>
#include <TextFinder.h>

int length = 0;
  
static uint32_t timer;

// Patterns and pattern buffer pointer
char *searchPattern[] = {
  "<code>"                    
};
char *searchPatternProgressPtr;

// Output bugger and pointer to the buffer
char displayBuff[64];
char testBuf[64];

char *outputBufferPtr;

int foundPatternState;// Initialsed in loop()


// Utility functions
void removeSubstring(char *s,const char *toremove)
{
  while( s=strstr(s,toremove) )
  {
    memmove(s,s+strlen(toremove),1+strlen(s+strlen(toremove)));
  }
}


// Function to find a string in a buffer, and return a pointer to the first char after the end of the match
// Returns pointer to NULL if a pattern is not found
// This function is designed to fing the search string across multiple buffers, and uses the patternInProgress pinter to store partial pattern matches
// The calling code needs to maintain patternInProgress between subsequent calls to the function.
char *multiBufferFindPattern(char *buffer,char *searchString,char *patternInProgress)
{
  while (*buffer && *patternInProgress)
  {
    if (*buffer == *patternInProgress)
    {
      patternInProgress++;
    }
    else
    {
      patternInProgress=searchString;// reset to start of the pattern
    }
    buffer++;
  }
  if (!*patternInProgress)
  {
    return buffer;
  }
  return NULL;
}

int getData(char *inputBuffer, char *outputBuffPtr, char endMarker)
{
  while(*inputBuffer && *inputBuffer!=endMarker && *outputBuffPtr)
  {
    *outputBuffPtr=*inputBuffer;
    outputBuffPtr++;
    inputBuffer++;

  }
  if (*inputBuffer==endMarker && *outputBuffPtr!=0)
  {
    *outputBuffPtr=0;
    // end character found
    return 1;
  }
  else
  {
    return 0;
  }
}


//Ethernet needs this
#define REQUEST_RATE 1000 // milliseconds
static byte mymac[] = {
  0x74,0x69,0x69,0x2D,0x30,0x31 };

char website[] PROGMEM = "frizzbar.nl";

byte Ethernet::buffer[400];

// request 2 remove other
static void browseUrlCallback (byte status, word off, word len)
{
  char *pos;// used for buffer searching
  pos=(char *)(Ethernet::buffer+off);
  Ethernet::buffer[off+len] = 0;// set the byte after the end of the buffer to zero to act as an end marker (also handy for displaying the buffer as a string)
  Serial.println((const char*) Ethernet::buffer + off);

  //Serial.println(pos);
  if (foundPatternState==0)
  {
    // initialise pattern search pointers
    searchPatternProgressPtr=searchPattern[0];
    foundPatternState=1;
  }

  if (foundPatternState==1)
  {
    pos = multiBufferFindPattern(pos,searchPattern[0],searchPatternProgressPtr);
    if (pos)
    {
      foundPatternState=2;
      outputBufferPtr=displayBuff;
      memset(displayBuff,'0',sizeof(displayBuff));// clear the output display buffer
      displayBuff[sizeof(displayBuff)-1]=0;//end of buffer marker
    }
    else
    {
      return;// Need to wait for next buffer, so just return to save processing the other if states
    }
  }    


  if (foundPatternState==2)
  {
    //Serial.println("Found HR start");
    if (getData(pos,outputBufferPtr,'<'))
    {
      Serial.print("Code ");
      Serial.println(displayBuff);

      long displayInt = atol(displayBuff);
      long codeInt = atol("9812");
      long faultInt = atol("6767");

      if (displayInt == codeInt)
      {
        Serial.print("Equal.");
      Consumption();
          

      }

      if (displayInt == faultInt)
      {
        Serial.print("Equal.");
        GeenSaldo();
        
      
      }

      String DisplayTAG = "";

      ether.persistTcpConnection(false);  //Move to next state (not used in this demo)
    }
    else
    {
        
        Beep(100);
        Beep(100);
        Beep(100);
        Beep(100);
        
      
      // end marker is not found, stay in same findPatternState and when the callback is called with the next packet of data, outputBufferPtr will continue where it left off
    }
  }
 
 Pauze();
}



// called when the client request is complete
static void my_result_cb (byte status, word off, word len) {

  Serial.print("<<< reply ");
  Serial.print(millis() - timer);
  Serial.println(" ms");
  Serial.println((const char*) Ethernet::buffer + off);


}

//Parallax RFID Reader

#define RFIDSerialRate 9600 //Parallax RFID Reader Serial Port Speed

//Using SoftwareSerial Library to locate the serial pins off the default set
//This allows the Arduino to be updated via USB with no conflict
#define RxPin 5 //Pin to read data from Reader
#define TxPin 4 //Pin to write data to the Reader NOTE: The reader doesn't get written to, don't connect this line.
SoftwareSerial RFIDReader(RxPin,TxPin);

String RFIDTAG=""; //Holds the RFID Code read from a tag
String DisplayTAG = ""; //Holds the last displayed RFID Tag

void setup()
{
  
   pinMode(3, OUTPUT);
   pinMode(6, OUTPUT);
   pinMode(7, OUTPUT);
   pinMode(9, OUTPUT);
   pinMode(10, OUTPUT);
  
  // RFID reader SOUT pin connected to Serial RX pin at 9600bps
  RFIDReader.begin(RFIDSerialRate);

  // Set Enable pin as OUTPUT to connect it to the RFID /ENABLE pin
  


  // Activate the RFID reader
  // Setting the RFIDEnablePin HIGH will deactivate the reader
  // which could be usefull if you wanted to save battery life for
  // example.


  Serial.begin(9600);           // set up Serial library at 9600 bps

  Serial.println("\n[getDHCPandDNS]");


  if (ether.begin(sizeof Ethernet::buffer, mymac) == 0)
    Serial.println( "Failed to access Ethernet controller");
    Beep(500);
    Blue(100);
    Beep(500);
    Blue(100);
    Blue(100);
    Blue(100);
    Blue(100);
    

  if (!ether.dhcpSetup())
    Serial.println("DHCP failed");

  ether.printIp("My IP: ", ether.myip);
  // ether.printIp("Netmask: ", ether.mymask);
  ether.printIp("GW IP: ", ether.gwip);
  ether.printIp("DNS IP: ", ether.dnsip);

  if (!ether.dnsLookup(website))
    Serial.println("DNS failed");

  ether.printIp("Server: ", ether.hisip);


  timer = - REQUEST_RATE; // start timing out right away

}

Pages: [1] 2 3