Recent Posts

Pages: [1] 2 3 ... 10
Hi guys. I'm using the arduino to communicate with a motor. The motor can receive the command I sent.
The serial monitor can read sign-in(copyright something like that). Then the serial monitor start to receive endless carriage return('\r'). I've used logic 8 to see the ascii signals that transfer between the arduino and the motor. It appears that the arduino is continuing receiving '\r\r\r\r\r\r\r'.. none stop. Is that anything wrong with my code?
Code: [Select]
int DE=2;
int LET=13;
//char b[]="SL 51200^M";//command need to input to the mdrive
SoftwareSerial mySerial(3,4);
String comdata="";//input command in the serial monitor
void setup() {
pinMode(DE, OUTPUT);

void loop() {
  //print receive data to the monitor
//code for input command in the serial monitor
 comdata += char(;
 comdata = "";
  if (comdata.length() > 0)
        Serial.print(comdata);//(show on the serial monitor)
        comdata = "";

Any suggestions is appreciated.
If you do not have a ground from the 5v signal source connected to an Arduino ground pin you will get "sporadic" readings.
Microcontrollers / Something is off with my timin...
Last post by Perehama - Today at 03:18 pm

I am trying to create a temperature probe using an LMT01 and an ATmega328P.
I have attached a schematic of my circuit.
Here is the code I am running.
Code: [Select]
volatile int pulseCount = 0;
int pulseTotal = 0;

void setup()
  ACSR = B01011010;    //Setup the Analog Comparator Register.

void loop()
  if (pulseCount != 0)
    while (pulseCount != pulseTotal)
      pulseTotal = pulseCount;
    float tCelsius = pulseCount * 0.0625 - 50;
    float tFahrenheit = tCelsius * 1.8 + 32;
    pulseCount = 0;

//Interrupt Service Routine, counts pulses
  pulseCount += 1;

Since I am using the internal OSC, I have the following boards.txt
Code: [Select] 328P 8MHz


I have fused the chip as follows:
Code: [Select]
avrdude -c usbasp -p m328p -U lfuse:w:0xe2:m
avrdude -c usbasp -p m328p -U hfuse:w:0xd9:m
avrdude -c usbasp -p m328p -U efuse:w:0x07:m

When looking at the serial output on an oscilliscope, the timing is way off 9600 baud.

I need it to be 9600 so attached equipment can read the data. What am I missing?
Arduino Due / Re: Keypad and playing wav wit...
Last post by atlaikesbriedi - Today at 03:17 pm
Apologies, my syntax was a bit off, been a long time since using pointers and char arrays instead of strings, I usually program C#.

I edited my code above in Reply #11, try that again.
Thanks! What was the issue first time? Only missing void playSound(const char* cName)?

It works, but the same way - with sound distortions. Such a weird problem.

It seems that I am missing     
Code: [Select]

But still figuring out where and how to implement it.
Motors, Mechanics, and Power / Re: I need an Adult haha
Last post by dougp - Today at 03:16 pm
Are you thinking of something like this?
Generale / leonardo si blocca dopo un pai...
Last post by cri_pava - Today at 03:16 pm
Buongiorno a tutti

Ho realizzato un apricancello collegando un leonardo eth ad un telecomando a 433Mhz (ho fattto questo perche' il telecomando in questione e' un rolling code , e non ho trovato soluzione piu rapida).

Il tuttto funziona tramite una pagine web.

Il tutto funziona perfettamente senza intoppi per 3-4 giorni. Dopo circa quattro giorni quando mi connetto alla pagina web , questa non viene caricata (premetto che viene caricada da una sd), e restituisce una pagina vuota.

Semplicemente spegno e riaccendo l'arduino e tutto riprende a funzionare regolarmente.

Qualche idea sul perche faccia cosi?

questo il codice arduino
Code: [Select]
#include <SPI.h>
#include <Ethernet2.h>
#include <SD.h>

// MAC address from Ethernet shield sticker under board
byte mac[] = { 0xB8, 0x27, 0xEB, 0x0B, 0xE6, 0x06 };
IPAddress ip(192, 168, 0, 168); // IP address, may need to change depending on network
IPAddress gateway(192, 168, 0, 1);
IPAddress subnet(255, 255, 255, 0);
EthernetServer server(80);  // create a server at port 80
File webFile;
String HTTP_req;            // stores the HTTP request

void setup()
   Serial.begin(9600);       // for diagnostics
  // initialize SD card
    Serial.println("Initializing SD card...");
    if (!SD.begin(4)) {
        Serial.println("ERROR - SD card initialization failed!");
        return;    // init failed
    Serial.println("SUCCESS - SD card initialized.");
    // check for index.htm file
    if (!SD.exists("index.htm")) {
        Serial.println("ERROR - Can't find index.htm file!");
        return;  // can't find index file
    Serial.println("SUCCESS - Found index.htm file.");
    pinMode(7, OUTPUT);// switch is attached to Arduino pin 3
    digitalWrite(7, LOW);
    pinMode(3, INPUT);
  Ethernet.begin(mac, ip, gateway, subnet);  // initialize Ethernet device
  server.begin();           // start to listen for clients
  Serial.print("Server is at");
  pinMode(7, OUTPUT);        // switch is attached to Arduino pin 3


void loop()
  EthernetClient client = server.available();  // try to get client

  if (client) {  // got client?
    boolean currentLineIsBlank = true;
    while (client.connected()) {
      if (client.available()) {   // client data available to read
        char c =; // read 1 byte (character) from client
        HTTP_req += c;  // save the HTTP request 1 char at a time
        // last line of client request is blank and ends with \n
        // respond to client only after last line received
        if (c == '\n' && currentLineIsBlank) {
          // send a standard http response header
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println("Connection: keep-alive");
          // AJAX request for switch state
          if (HTTP_req.indexOf("opengate") > -1) {

            digitalWrite(7, HIGH);
          int readopened = digitalRead(3);
            digitalWrite(7, LOW);
           if(readopened = HIGH){
            if(readopened = LOW){
          else { 
            // web page request
                        // send web page
                        webFile ="index.htm");        // open web page file
                        if (webFile) {
                            while(webFile.available()) {
                                client.write(; // send web page to client
          // display received HTTP request on serial port
          HTTP_req = "";            // finished with request, empty string
        // every line of text received from the client ends with \r\n
        if (c == '\n') {
          // last character on line of received text
          // starting new line with next character read
          currentLineIsBlank = true;
        else if (c != '\r') {
          // a text character was received from client
          currentLineIsBlank = false;
      } // end if (client.available())
    } // end while (client.connected())
    delay(1);      // give the web browser time to receive the data
    client.stop(); // close the connection
  } // end if (client)

questa la pina web
Code: [Select]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  <link rel="icon" href="/favicon.ico" type="image/ico">
    body {
   height: 100%;
    div {
    margin: 0 0 0 0;
   button {
    width: 4em;
    height: 1.5em;
     color: #32CD32;
     color: #FF0000;
     color: #FF0000;
     font-weight: bold;
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <meta name="generator" content="PSPad editor,">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    function Openthegate() {
             nocache = "&nocache="+ Math.random() * 1000000;
             var request = new XMLHttpRequest();
             request.onreadystatechange = function() {
          if (this.readyState == 4) {
            if (this.status == 200) {
              if (this.responseText = "opened") {
                 document.getElementById("opened").innerHTML = "Opened";
              else if (this.responseText = "notopened") {
                 document.getElementById("notopened").innerHTML = "Something wrong, check the gate!!";
                 document.getElementById("error").innerHTML = "ERROR, CALL CRISTIAN"; 11
  "POST", "opengate" + nocache, true);
          <div >
            <button type="button"  onclick="Openthegate()">Apri</button>
            <p id="opened"></p>
            <p id="notopened"></p>
            <p id="error"></p>

Grazie a tutti per l'aiuto
Deutsch / Re: kann mir mal jemand den co...
Last post by uwefed - Today at 03:14 pm
kann man das umbauen ohne serial.peekn um das per swserial zu nutzen?!

und was heisst... i-te byte?!
erste, zweite,..., i-te

das i-te ist die Ordinalzahl von vom wert der Variable i.

Grüße Uwe
Please post your latest code including the attempt to use printLcdDate().
Did the Serial.print() statements did put the data out in the required format (but of course to the serial console) ?
Deutsch / Re: Motortreiber L293D Problem...
Last post by uwefed - Today at 03:10 pm
Ich habe die Schaltung nicht verstanden und darum kann ich nicht antworten.
Deutsch / Re: LED_Cube mit Arduino Nano....
Last post by uwefed - Today at 03:09 pm
Für die Anoden brauchst Du PNP Transistoren oder P-MOSFETS. Der TIP31 für die Kathoden ist ok.

Du kannst den Kollektorstrom nicht über den Basisstrom bestimmen. Die Stromverstärkung ist nicht konstant. Du brauchst auf alle Fälle Vorwiderstände an den Anoden der LED.

Die Basiswiderstände rechnet man daß der Transistor  sicher durchschaltet (Richtwert daß 2-3x Laststrom bei min Verstärkung)

Grüße Uwe
Pages: [1] 2 3 ... 10