text:
How to send information from a web-site to the arduino?
I currently have an Arduino Mega + an Arduino Ethernet shield, I would like to know if it's possible to send data to the arduino from a web-site hosted on the shield itself. So that when someone press a Button on the web-site it sends a signal to the arduino to trigger an action. Could anyone kindly help me.

Have you tried typing this question into Google?  There are many, many examples of this being done.

@MarkSmith There aren't in the specific way am trying, and I tried stack since its friendly to me compared to google which will bring me to spam sites, yet I didn't found my answer off google, it wasn't precise.

Yes of course!
First things first - Yes, it is possible to accomplish what you're thinking.
The idea is to create a server on the Ethernet Shield and open the webpage hosted by it on any device and based on the options selected on the web page we can trigger desired actions on the Arduino.
I've modified the web server code of Arduino built-in examples to match your requirements, just upload it and make necessary changes as required, here it is-
#include<SPI.h>
#include<Ethernet.h>

byte mac[] = {
   0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02
 };

 IPAddress ip(192,168,1,199); // Any ip address not on your network.
 EthernetServer server(80);   // Port 80 is default for http.

  int led=2;

  String request;

  void setup(){
    Ethernet.begin(mac,ip);
    pinMode(led,OUTPUT);
    Serial.begin(9600);
   }

  void loop(){

      EthernetClient client = server.available();
  if(client)
         {
       Serial.println("Client is trying to connect......");
       while(client.connected())
       {
  if(client.available())
  {
    char c = client.read();
    request.concat(c);
    if(c=='\n'){
    Serial.print(request);
    if(request.indexOf("ON")>0){
      digitalWrite(led,HIGH);
      Serial.println("ON");
      }

      else if(request.indexOf("OFF")>0){
        digitalWrite(led,LOW);
        Serial.println("OFF");
        }
    client.println("HTTP/1.1 200 OK");
    client.println("Content-Type: text/html");
    //client.println("Refresh: 5");  // refresh the page automatically every 5 sec
    client.println();

    client.println("<!doctype html>");
    client.println("");
    client.println("<title>LED</title>");
    client.print("<!DOCTYPE HTML>
LED ON

LED OFF

" );
    client.println("");
    client.stop();
    request="";

  }
  }
 }

    }

   }

This sketch will turn an LED on or off attached to digital pin 2.
You have to go to the IP address that you provide to the shield (192.168.1.199 in my case). You'll see 2 hyperlinks to switch on or off the led and that would pass a query which the Arduino looks for again and again in the loop and takes action accordingly.
Hope this helps, try this out, and do let me know the result.
NOTE
Make sure that you access the Ethernet Shield from a device within your LAN only otherwise you'll have to use port forwarding.

It work all fine, yet I don't know if it's possible to have another file on the SD card in HTML and CSS to do the same exact thing. Instead of having an entire web-page in the sketch itself.

Obviously that's possible! Give me a day or two I'll help you out

The only limitation to the applications of an arduino is the user's imagination! :)

I completely agree :D I always say that :D 8

Actually I understood what you doing here, you using the URL to determine if the LED is on or off, but I want a way where I can communicate with the arduino from the Web-Site Interface sending and receiving information.

That is what it is,  The process of parsing the url includes the query operator ('?') this operator would take our link and place it in the url under the same domain (IP in our case) and when the server (Arduino) gets the request it toggles the LED accordingly.

Hum isn't there any other way such as Serial to communicate to the arduino from  a web interface.

Let us continue this discussion in chat.

https://startingelectronics.org/tutorials/arduino/arduino-MEGA-24-output-web-server/ I found this article. They did pretty much the same thing using Ajax


text:
while(1) loop blocks program to enter interrupt
I want to build a program in C that enables / disables a passive matrix display. But my problem occurs before I can even implement one function of this display.
I have a simple switch connected to Port C pin 24, which is configured as INPUT with a pull-up resistor and debouncing input filter. When I toggle the switch the code enters an interrupt and toggles the "display" on or of depending on the state of the switch.
Everything works fine until I introduce a simple while(1) loop, which should handle everything I want to do. But every time I write the function called run, which only contains one while(1) loop and a single dummy operation __asm__("nop"), the while loop prevents the code from entering the interrupt.
This is my code:
void display_init(void) {
    sysclk_init();
    delay_init(sysclk_get_cpu_hz());
    pmc_set_writeprotect(false);
    pmc_enable_periph_clk(ID_PIOC);
    NVIC_EnableIRQ(PIOC_IRQn);
    REG_PIOC_PER = SWITCH;
    REG_PIOC_ODR = SWITCH;
    REG_PIOC_OWDR = SWITCH;
    REG_PIOC_PUER = SWITCH;
    REG_PIOC_IFER = SWITCH;
    REG_PIOC_DIFSR = SWITCH;
    REG_PIOC_LSR = SWITCH;
    REG_PIOC_REHLSR = SWITCH;

    //Clear input change register to avoid immediate interrupt
    REG_PIOC_ISR;
    REG_PIOC_IER = SWITCH;
    run();
}

void run() {
    while(1) {
        __asm__("nop"); //Dummy operation for debugging
    }
}

void PIOC_Handler(void) {
    REG_PIOC_ISR;
    if(REG_PIOC_PDSR & PIO_PC24) {
        __asm__("nop"); //Breakpoint
    } else {
        __asm__("nop"); //Breakpoint
    }
}

As far as I know, an interrupt stops everything executed at the current time and starts working on the interrupt code. My question is now: Why is the interrupt not stopping the while loop?
Before I recognized this problem, I had a simple condition in the while loop that checks whether 1 or 0 to equals 1 when I set this state to 0, so the condition was 1 == 0 which should equal false. The loop did not stop and continued to run even if the condition for this loop was false... Is it possible that while loops do not like to be used in parallel with interrupts?
EDIT:
void main(void) {
    board_init();
    display_init();
}

I don't have an Arduino setup() function because I'm using Atmel Studio to ensure working at low Level, to avoid unnecessary code and to keep memory usage as low as possible.

This is not an Arduino question - you are not using the Arduino software framework or tools, and you are not using classic Arduino hardware.  Essentially what you have here is a software problem, in a more generic microcontroller context.

How do you even know if the interrupt is hit or not?   Also, consider the possibility that the interrupt was not being hit in the previous case, but the execution was falling through to it.

Is it possible that while loops do not like to be used in parallel with interrupts? Of course not. Do you think if you use interrupts you can't use while loops? You may as well not use for loops. It is impossible to answer without seeing all of your code. Please make a minimal example that demonstrates what you are talking about.

The while loop should have no effect on interrupts. Where does run() get called? We'll need to see the code that sets up and calls the code you've shown. But as a sanity check, you could try replacing the entire contents of run() with a ;, that is make it an empty function. Then add in an empty while loop (contains only a ;, no __asm__ code) and try again. Then replace the body of the while loop with __asm("nop")__ and try again. At which of the above steps does your interrupt fail? That should lead you in the right direction.
Update:
What does your main() function do after display_init() returns? Because that won't ever happen when run() runs forever.
The job of main() is to create the C/C++ run-time environment. That may not have been completed (enabling interrupts, for instance) when display_init() and run() get called, but gets completed shortly after they returns - if run() is allowed to end.
Without seeing your main(), we can't know enough to be more specific, but I'd suggest you move all of your code out of main() and down into the Arduino setup() function because, by the time it gets called, the run-time environment will be complete.
Update 2:

to avoid unnecessary code

If that is your entire main() function, you've left out the run-time environment setup and it's little wonder that your code behaves strangely. You've asked for help and we've made some suggestions: to show your entire code, not just selected pieces of it; and run your code in a standard way and let us know the result. Then you can optimize your code if you feel it's worth it to you. When you've done that test, and you still have questions, ask again. Until then, you're just asking us to guess. We did that. Once.

I call the run()method in the display_init() function at the top of my code. The init function is called by the main() function of the code. I tried it with an empty run() method. The interrupt worked as expected. But at the moment where I placed any type of while loop the interrupt fails. Even with an empty loop. Only if I replaced it with a while(0) loop it worked but with this the code is not working because it is not a loop anymore.

Sounds like interrupts aren't enabled. Bear in mind that an empty run() method is likely to be optimized away by the compiler.

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

sort: votes


text:
MFRC522 not scanning card
So I have an Arduino Uno and an MFRC-522 reader, using a breadboard I've wired it up according to the example sketch which is the mfrc522 DumpInfo sketch.
/*Typical pin layout used:
 *
 *             MFRC522      Arduino
 *             Reader/PCD   Uno/101
 * Signal      Pin          Pin
 * -------------------------------
 * RST/Reset   RST          9
 * SPI SS      SDA(SS)      10
 * SPI MOSI    MOSI         11 / ICSP-4
 * SPI MISO    MISO         12 / ICSP-1
 * SPI SCK     SCK          13 / ICSP-3
 */

I've checked the wiring hundreds of times. The console shows
    Firmware Version: 0x92 = v2.0
    Scan PICC to see UID, SAK, type, and data blocks...
but getting a card near the chip, will not scan or dump any info no other information appears on the serial monitor.
I've tried with mifare classic 1k  cards
a Nexus 6
and a Samsung Galaxy S7
Edit: Everything
    /*
    * ------------------------------------------------------------------------------------------------------------------
    * Example sketch/program showing how to read data from a PICC to serial.
    * --------------------------------------------------------------------------------------------------------------------
    * This is a MFRC522 library example; for further details and other examples see: https://github.com/miguelbalboa/rfid
    *
    * Example sketch/program showing how to read data from a PICC (that is: a RFID Tag or Card) using a MFRC522 based RFID
    * Reader on the Arduino SPI interface.
    *
    * When the Arduino and the MFRC522 module are connected (see the pin layout below), load this sketch into Arduino IDE
    * then verify/compile and upload it. To see the output: use Tools, Serial Monitor of the IDE (hit Ctrl+Shft+M). When
    * you present a PICC (that is: a RFID Tag or Card) at reading distance of the MFRC522 Reader/PCD, the serial output
    * will show the ID/UID, type and any data blocks it can read. Note: you may see "Timeout in communication" messages
    * when removing the PICC from reading distance too early.
    *
    * If your reader supports it, this sketch/program will read all the PICCs presented (that is: multiple tag reading).
 * So if you stack two or more PICCs on top of each other and present them to the reader, it will first output all
 * details of the first and then the next PICC. Note that this may take some time as all data blocks are dumped, so
 * keep the PICCs at reading distance until complete.
 *
 * @license Released into the public domain.
 *
 * Typical pin layout used:
 * -----------------------------------------------------------------------------------------
 *             MFRC522      Arduino       Arduino   Arduino    Arduino          Arduino
 *             Reader/PCD   Uno/101       Mega      Nano v3    Leonardo/Micro   Pro Micro
 * Signal      Pin          Pin           Pin       Pin        Pin              Pin
 * -----------------------------------------------------------------------------------------
 * RST/Reset   RST          9             5         D9         RESET/ICSP-5     RST
 * SPI SS      SDA(SS)      10            53        D10        10               10
 * SPI MOSI    MOSI         11 / ICSP-4   51        D11        ICSP-4           16
 * SPI MISO    MISO         12 / ICSP-1   50        D12        ICSP-1           14
 * SPI SCK     SCK          13 / ICSP-3   52        D13        ICSP-3           15
 */

#include <SPI.h>
#include <MFRC522.h>

#define RST_PIN         9          // Configurable, see typical pin layout above
#define SS_PIN          10         // Configurable, see typical pin layout above

MFRC522 mfrc522(SS_PIN, RST_PIN);  // Create MFRC522 instance

void setup() {
    Serial.begin(9600);     // Initialize serial communications with the PC
    while (!Serial);        // Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4)
    SPI.begin();            // Init SPI bus
    mfrc522.PCD_Init();     // Init MFRC522
    mfrc522.PCD_DumpVersionToSerial();  // Show details of PCD - MFRC522 Card Reader details
    Serial.println(F("Scan PICC to see UID, SAK, type, and data blocks..."));
}

void loop() {
    // Look for new cards
    if ( ! mfrc522.PICC_IsNewCardPresent()) {
        return;
    }

    // Select one of the cards
    if ( ! mfrc522.PICC_ReadCardSerial()) {
        return;
    }

    // Dump debug info about the card; PICC_HaltA() is automatically called
    mfrc522.PICC_DumpToSerial(&(mfrc522.uid));
}

datasheet Nxp website /documents/data_sheet/MFRC522.pdf

Phones mosly use NFC which is at a higher freaquency then RFID. Are you sure they are even compatible?

Pretty positive, But I also used many MiFare Classic cards which this reader is explicitly stated to be compatible with. with absolutely no results

Can you post the whole post please?

Edited main post

Have you read MFRC522.h? It seems the 1K tags have a specific type of authentication. Also, be sure that the device has adequate power, during transmit it may suddenly use a lot more power. You may ultimately try another reader or card, to exclude any possible hardware defects in the antenna circuitry.

your breadboard can be buggy. In addition, are you connected VCC to 3V or 5V?
As I remember, you need to connect it to 3V.

#include <SPI.h>
#include <MFRC522.h>

void setup() {
  Serial.begin(9600);
  SPI.begin();
  RFID.PCD_Init();      // MFRC522
}
#define SS_PIN 10
#define RST_PIN 9

MFRC522 RFID(SS_PIN, RST_PIN);

void loop() {
  if (!RFID.PICC_IsNewCardPresent() || !RFID.PICC_ReadCardSerial())
    return;

  String buffer;
  for (byte byte = 0 ; byte < RFID.uid.size ; byte++)
    buffer += String(RFID.uid.uidByte[byte] < 0x10 ? " 0" : " ") + String(RFID.uid.uidByte[byte], HEX);
  Serial.println("NUID: " + buffer);

  RFID.PICC_HaltA();
  RFID.PCD_StopCrypto1();
}

I had a similar problem. I used I2C to check if the board can see the reader. If I2C Bus doesn't detect your reader, then one of your soldering must be faulty... check with a meter and carefully re-solder the erring pin.

The OP says "the console shows Firmware Version: 0x92 = v2.0". This effectively means that there is a working connection with the reader. So any advice on resoldering doesn't seem useful at all.

I have several of this board with this condition. As I checked ,they all return the same thing as you send in SPI . I think all of them have hardware problem. Common thing for all of them is In past I supplied them with switching supply and I think this is why they got broken(this chip is very sensitive with supply voltage and YOU MUST NOT CONNECT THEM TO MORE THAN 3.3V EVEN FOR VERY SHORT TIME) . I highly recommend use of Linear regulator for them

Same problem as above. Three card readers. Two worked. One didn't. All three  readers had two pins bridged on the reader chip. The bridged pins were close to the pin 1 corner. I left the bridge alone as all three readers had the same bridge and one of the pins did not have a trace to it. The faulty card reader also had two pins bridged with solder in a different location. Both pins had separate traces. I removed the solder bridge and the faulty card reader was no longer faulty.

I figured out that one get these kind of problems (reader get´s firmware version but can not read tags) are related to power consumption. I tried to power the reader with Heltec Lora 32 Dev board and it schowed exactly this behaviour. Now, connected to another 3,3V source everything works as it should :)

Maybe you need a function TO PRINT THE READINGS!!!
This is the loop and a function to print it:
void loop() {
  if ( ! rfid.PICC_IsNewCardPresent())
    return;
  if ( ! rfid.PICC_ReadCardSerial())
    return;

    for (byte i = 0; i < 4; i++) {
      nuidPICC[i] = rfid.uid.uidByte[i];
    }

    Serial.println(F("The NUID tag is:"));
    Serial.print(F("In hex: "));
    printHex(rfid.uid.uidByte, rfid.uid.size);

  rfid.PICC_HaltA();
  rfid.PCD_StopCrypto1();
}

void printHex(byte *buffer, byte bufferSize) {
  for (byte i = 0; i < bufferSize; i++) {
    Serial.print(buffer[i] < 0x10 ? " 0" : " ");
    Serial.print(buffer[i], HEX);
  }

}

mfrc522.PICC_DumpToSerial(&(mfrc522.uid));
Already prints to serial. It's almost like I actually know what I'm doing as far as code goes.
in fact I already have my whole project written for this card. it just seems to not actually read anything.

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
IR communication not consistent
I have an IR Receiver hooked up to my arduino and a remote with an IR Trasmitter in it. I have some code to decode the values that are received but the values change even when I am pressing the same button!
Here is the code I am using:
#include <IRremote.h>

int IRpin = 8;
IRrecv irrecv(IRpin);
decode_results results;

void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn();
}

void loop()
{
  if (irrecv.decode(&results))
    {
      Serial.println(results.value, HEX);
      irrecv.resume();
    }
}

and here is me pressing the same button 10 times and the output for it:

9C01C8E1
  FFFFFFFF
  82A6A14C
  FFFFFFFF
  FFFFFFFF
  70D67871
  FFFFFFFF
  BCB5C227
  FFFFFFFF
  B358F5ED
  FFFFFFFF
  FFFFFFFF
  FFFFFFFF
  FFFFFFFF
  FFFFFFFF
  FFFFFFFF
  58EE9A27
  FFFFFFFF
  90750A0D
  FFFFFFFF
  FFFFFFFF
  FFFFFFFF

Maybe the hardware is wrong. Can you show your wiring?

@NickGammon https://circuits.io/circuits/3614549-the-unnamed-circuit/edit#breadboard Its a 470 Ohm resistor.

Which IR receiver do you have? Not all of them require a resistor. See here. Also maybe you have the pins the wrong way around.

Try using a different remote...

It is not the remote that encodes the signals, it is the IR receiver. Changing the remote would do nothing.

@NickGammon I solved it.

Get TSOP1738 or any good IR receiver to decode. Above code is appropriate and does not need any changes. you will surely get some fluctuations and different decoded hex codes but it would provide only 2 different values for single button so that while controlling any device using ir , you can use 'or' operator in conditional statement and hence you will get desired results.
Getting absolute results from a cheap IR receiver is a myth.But it will work well for your project at lower level.I had worked with that and my device is working in my room with no difficulty.

You were right. The IR receiver that I had isn't yet supported by the IRremote library.

I eventually figured it out. The IR Receiver that I had was made by a company called Sharp. Every company has different methods of encoding and decoding IR signals, and it just so happens that decoding Sharp messages is not yet supported in the IRremote library, the library I was using for IR communication. I found a different IR receiver from an old electronic device that I had, I tried that and it worked perfectly.


text:
Arduino pins LCD and motor controller
I am using an L298N motor control. I want to use my 2*16 LCD. Can I use the code like this?
// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(RS, E, D4, D5, D6, D7);
LiquidCrystal lcd(12, 9, 4, 5, 6, 7);

// Motor Control
#define enableA  3
#define enableB  11
#define in1 4
#define in2 5
#define in3 6
#define in4 7

You can not use pins that are used by the LCD for your motors, you have to use other pins.

No, you can't use that pins for both. Use other pins.

You cannot use the pins for distinct purposes at the same time, however as you have the enable pins to the motor drivers wired up, you may be able to communicate with the LCD with the motors disabled, and then drive around while not communicating with the LCD (and making sure not to activate its strobe).

Using that pin configuration you'll have several problems despite you'll use enable pin.
I would use a I2C module for 16x2 lcd like this https://www.amazon.com/SainSmart-Serial-Module-Display-Arduino/dp/B00813HBEQ
Control 16x2 lcd with I2C.

You will need two 16x2 LCD with different I2C addresses.

You cannot use same pins for LCD and motor. Data transfer through pins 4,5,6,7(being data pins for LCD) will effect your motor state. You should use different pins and if you does not have sufficient digital pins so you can use analog pins as digital pins (0-LOW,255-HIGH).

What's the 0-LOW 255-HIGH part about?  Surely you are talking about the analog inputs that can also be used as digital pins.  The analog outputs are already all on digital pins.  With the analog pins you'd use pinMode and digitalWrite(pin, LOW) or digitalWrite(pin, HIGH) just like with any other digital pin.

You can use the same pins for both the motor and the LCD.
A condition is that the enable pin decides when the LCD or the motor is accepting inputs from the data pins. This is a normal bus configuration, several devices share data pins and have a enable pin to tell the device when they owns the data bus.


text:
Removing Robot IR Arduino Library on Macbook
I'm trying to use my IR receiver on my Arduino Uno Board.  First I need to remove my IR Robot library because it interferes with the IRremote library. On my Mac, I have gone into the Arduino/library folder, but the name of the library I have to remove is not there.
I cannot figure out how to remove this. Please help!!

The folder name is RobotIRremote.
It's actually not necessary to remove that folder, though that will solve your problem. A better solution is to change the folder name of the IRremote remote library so that the file named IRremote.h found in that library will be given include priority over the one found in the RobotIRremote library. This is better because you would need to remove the RobotIRremote library every time you update to a new version of the Arduino IDE. The Arduino IDE gives include priority to files that match the name of the library folder but unfortunately if you install the IRremote library manually it will tend to have the folder name Arduino-IRremote-master which causes the wrong file to have priority. So you just need to find that folder and rename it IRremote.
If you don't know where it is the library folder can be found by:

File > Examples > IRremote > AiwaRCT501SendDemo
Sketch > Show Sketch
Folder

So the library name for me is already IRremote, not Arduino-IRremote-master. Still not sure what to change. Also, I don't have a folder name called AiwaRCT501SendDemo under the IRremote --- instead its JVCPanasonicSendDemo.

You not having that example sketch name indicates you're using a different/outdated version of the Arduino-IRremote library. Please post a link to where you downloaded your IRremote library from. Also, please state which version of the Arduino IDE you're using. FYI, the steps to finding the library folder I posted above will work with any example from the library. I just used AiwaRCT501SendDemo because that was the first one shown on the menu for me.

Okay so I just downloaded the latest IRremote library, and it was named Arduino-IRremote-master. So all I have to do is change the name of that library to IRremote and it will work? Also, sorry for the confusion on my end, I'm just beginning with Arduino. Thank you!

Yes, change the name and replace your previous installation of the library with the new one and it should work.

It's not working. I changed the name from Arduino-IRremote-master to IRremote and removed the old IRremote, and it's not working still. Is there anything else I could be doing to make this work?

You still haven't said which version of the Arduino IDE you're using. My tests with the latest version show this should work but the behavior might be different on older IDE versions. You could always just delete the RobotIRremote library.


text:
Controlling DC motor using the Servo pins
I have a L293D motor shield for arduino uno. It has capability of controlling 2 servo motors and 4 DC motors. But I want to control 5 DC motors for my project. So my question is can I use the 3 pins that are there in motor shield ( to control servo motors) for controlling a DC motor? Or any other solution if any without using any other hardware?

No. A servo motor has its own built-in driver and you just send a low-level PWM signal to control it. That cannot directly drive a DC motor.
If you want more DC motors you will need more DC motor driving hardware.  For simple speed control in one direction that could be as simple as a NPN transistor (or N-channel FET), a base resistor, and a flyback diode (just like driving a relay). For direction control you will need a H-bridge like the L293D (which incidentally is a very poor choice of driver by today's standards - very inefficient and lossy. I wish people wouldn't persist in selling it.)


text:
Adapt a differently pin-interspaced chip to be used with an Arduino
Happy new year to everyone!
This is how my chip looks like:

Those numbers are millimeters. Both the pin spacing and pin width are different from what Arduino uses.
Is there any quick (or less quick) and reliable way to connect this chip to an Arduino Uno ?

It is not clear what you intend to do, but why not simply use wires and soldering?

@jfpoilpret Based on my tools, ability and the scheme above I would think I could not do it. The pin rows are too tightly spaced.

I'd use some solid copper wire, similar to shown in this video https://youtu.be/5iIcGaf7qPA?t=411 (6:51)

Wire wrap is an old technology, that may work best on the intended long square pins, but it will work on shorter headers like this too, and you can usually fit the tool between 2mm pins as well as the intended 2.54 mm ones.  It can thus be a handy semi-permanent way to make these connections without getting out the soldering iron (or getting solder on pins you may want to repurpose later), and you can always solder it later as well to overcome any long-term reliability questions from using wrapping on the wrong shape of pins.

The simplest option is to buy a pre-made ribbon cable with 2mm pitch (7x2) IDC connector on it.
Solder the free end (or cut the second connector off and strip it if you have a two-ended cable) and solder it to strip-board on which you have already soldered a 14-pin header for breadboard use.

An example of the cable I mean.

this inspired me to go through the junk heap of cables and I have found an old parallel cable that I hacked for my purpose.

Adapters from 2mm to 2.54mm (0.1") spacing exist.
Here is
an example and another example.
Alternatively you could make up a little PCB or, as suggested by @jfpoilpret, solder wires on.
A further option is to cut a piece of stripboard, score down the middle to break the tracks, stick your chip on, and run wires from the 2mm-spaced pins to the 2.54mm-spaced pins.  Off-cut resistor legs work fairly well, in my experience.  Here's one I made (fairly clumsily) earlier.  Your soldering skill may be better than mine. .

Thanks MArk; two problems with those adapters -first I would not want to wait for them a couple of weeks until they eventually reach me and they can only do one row of pins whereas my chip got 14 pins on two rows (7 + 7). Could you expand on making my own PCB ? Is that fast ? What do I nee for that ?

Clarified that there are two links in my answer. The wires would do the trick, or you could use two of the boards, one on each side.  Making your own PCB would be time-consuming and fairly difficult to do well (drilling it particularly, in my opinion and for my level of skill), and you'll have to wait just as long for the stuff to do it.  Google or YouTube will tell you how to do it, I'm sure.


text:
Arduino - Windows can't find the drivers
I bought an Arduino UNO R3 Yesterday. It's a Chinese clone. But it has the Atmega328p and MEGA16U2 both.
I've installed the IDE fully. But it can't find the ports. The Tools > Ports option is greyd out, Cannot find The options Named "Ports (COM & LPT)" or "Other Devices" in device manager. Can't upload any sketch to board.
I tried this on my both Win7 SP1(32 BIT) & Win10, which are installed in the same pc but in different partitions. I've roamed accross stackexchange but no successful result.

Have you tried a different USB cable?

There's no issue with my cable I think. The green & orange both LEDs light up when plugged in.

That only means it's getting power. Some cheap (especially chinese) cables don't have data wires, only power wires. Try another cable. One you know for certain works.

That might be. But the drivers ought to be show themselves in the device manager. Or do they require proper connection?

The drivers don't show, only the device shows. If the device isn't detected there will be nothing there. Windows contains thousands of drivers. If the device manager listed the drivers instead of the detected devices it would be completely unmanageable.

I've tested my usb cable and it has data wires inside. And they're all conducting.

Let us continue this discussion in chat.

Maybe they forgot to install the firmware in the ATMega16U2?

You may not have installed the drivers when installing the IDE. The only way I know to reinstall the drivers is to reinstall the IDE and make sure when you get to this screen you tick every box:

Otherwise you may not have selected your board correctly. To select your board in the IDE, go to Tools > Board > Arduino Uno/Genuino Uno
Your port select may then appear, it should be COM1 or something similar. If you have multiple, just try them all by selecting one and then upload a sketch to it. The Arduino Uno should flash some lights if it worked correctly.


text:
Arduino with 2 echo sensors
For a project I'm doing I need the Arduino to be connected to two echo sensors (I have the HC-SR04). Currently I have 4 sensors that I can use, but I will need only 2 or 3.
I have almost no knowledge of coding and the Arduino, but I figured out how to connect it to one echo sensor, and that is working, which is great.
But now I need it to connect to two. I found example code with 3 echo sensors, but whenever I connect them my Arduino shuts down. I guess it is because it takes up too much power, my teacher said something like that. All lights turn off all of the sudden, and it doesn't reset. Only when I remove some the wires for the power, it works again.
So 3 isn't going to work. I figured I'd stick to two. Now the problem: Whenever I try to edit the code to two echo sensors (I basically just removed the trigPin3 and echoPin3 in the first part of the code, and the SonarSensor(trigPin3, echoPin3)), it doesn't work anymore. The monitor doesn't show any values anymore, while it did with the first code. It just shows zeroes now.
So my question is, how can I edit the example code so that it works with 2 echo sensors?
This is the code I found for the 3 echo sensors:
#define trigPin1 3
#define echoPin1 2
#define trigPin2 4
#define echoPin2 5
#define trigPin3 7
#define echoPin3 8

long duration, distance, RightSensor,BackSensor,FrontSensor,LeftSensor;

void setup() {
  Serial.begin (9600);
  pinMode(trigPin1, OUTPUT);
  pinMode(echoPin1, INPUT);
  pinMode(trigPin2, OUTPUT);
  pinMode(echoPin2, INPUT);
  pinMode(trigPin3, OUTPUT);
  pinMode(echoPin3, INPUT);
}

void loop() {
  SonarSensor(trigPin1, echoPin1);
  RightSensor = distance;
  SonarSensor(trigPin2, echoPin2);
  LeftSensor = distance;
  SonarSensor(trigPin3, echoPin3);
  FrontSensor = distance;
  Serial.print(LeftSensor);
  Serial.print(” – “);
  Serial.print(FrontSensor);
  Serial.print(” – “);
  Serial.println(RightSensor);
}

void SonarSensor(int trigPin,int echoPin) {
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH);
  distance = (duration/2) / 29.1;
}

And this is the one that IS working, but with 1 echo sensor:
#define echoPin 7 // Echo Pin
#define trigPin 8 // Trigger Pin
#define LEDPin 13 // Onboard LED

int maximumRange = 200;
int minimumRange = 0;
long duration, distance;

void setup() {
  Serial.begin (9600);
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  pinMode(LEDPin, OUTPUT); // Use LED indicator (if required)
}

void loop() {
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH);
  if (distance >= maximumRange || distance <= minimumRange) {
    /* Send a negative number to computer and Turn LED ON
    to indicate "out of range" */
    Serial.println("-1");
    digitalWrite(LEDPin, HIGH);
  } else {
    /* Send the distance to the computer using Serial protocol, and
    turn LED OFF to indicate successful reading. */
    Serial.println(distance);
    digitalWrite(LEDPin, LOW);
  }
  //Delay 50ms before next reading.
  delay(50);
}

I hope someone can help me!
Many thanks, Leah.

Could you update your question to add the code that you've created to work with two sensors, which doesn't work, please? Could you please also elaborate on what you mean by "doesn't respond anymore"? What exactly  does happen?

With "Doesn't respond anymore" I mean, lights turn off completely.

Elaborated some things in my question. I hope it's a little bit more clear now.

We can easily find working code on our own.  What we need is your "not working code".  BTW, instead of listing the working code, most simply provide a link to the working code.  As most get their code from other people's web pages or sources such as github.

There is a magical " delay(50);" that you might have omitted *<:)

Your "SonarSensor" function is quite odd, it probably works, bit it's not really neat. You also seem to start with a capital on some variable's names. The function "SonarSensor" looks like a constructie of a SonarSensor class. You may want to name it like: "getDistance" or "getDistanceFromSonar" and return the distance instead of modifying a global variable.

There is no link to a code, since I got my code from some classmates of mine, and from one of my teachers, that again probably found it somewhere (I don't know the source.) As for the "SonarSensor" function. I will change the name, thank you very much :) About the "Delay(50);", I see that this is indeed in the previous code, that was working. But I don't quite understand what it does exactly.

In the 1 sensor program all the delays added together account for
62ms between samples.
In the 3 sensor program the sample code contains delays which likely
exceed 12ms (delays plus code execution).  So each sensor will not be
sampled faster than once every 36ms.
After you removed 1 sensor from the 3 sensor program, you increased
the sampling rate to about every 23ms.
It is likely a minimum amount of time is necessary between samples in
order for the HC-SR04 to recover.

Try this one. I hope this will work for you.
int trigPin1 = 2;                        //Sensor Trip pin connected to Arduino pin 2
int echoPin1 = 3;                        //Sensor Echo pin connected to Arduino pin 3

int trigPin2 = 4;                        //Sensor Trip pin connected to Arduino pin 4
int echoPin2 = 5;                        //Sensor Echo pin connected to Arduino pin 5

float pingTime1;                         //time for ping to travel from sensor to target and return
float targetDistance1;                   //Distance to Target in centi meters

float pingTime2;                         //time for ping to travel from sensor to target and return
float targetDistance2;                   //Distance to Target in centi meters

float speedOfSound = 760.5583392985;     //Speed of sound in miles per hour.

void setup()
{
  pinMode(trigPin1, OUTPUT);
  pinMode(echoPin1, INPUT);

  pinMode(trigPin2, OUTPUT);
  pinMode(echoPin2, INPUT);
}

void loop()
{
  ultrasonicFun1();
  ultrasonicFun2();
}

void ultrasonicFun1()
{
  digitalWrite(trigPin1, LOW);         //Set trigger pin low
  delayMicroseconds(2000);             //Let signal settle
  digitalWrite(trigPin1, HIGH);        //Set trigPin high
  delayMicroseconds(15);               //Delay in high state
  digitalWrite(trigPin1, LOW);         //ping has now been sent
  delayMicroseconds(10);               //Delay in high state

  pingTime1 = pulseIn(echoPin1, HIGH);             //pingTime is presented in microceconds
  pingTime1 = pingTime1 / 1000000;                 //convert pingTime to seconds by dividing by 1000000 (microseconds in a second)
  pingTime1 = pingTime1 / 3600;                    //convert pingtime to hourse by dividing by 3600 (seconds in an hour)
  targetDistance1 = speedOfSound * pingTime1;      //This will be in miles, since speed of sound was miles per hour
  targetDistance1 = targetDistance1 / 2;           //Remember ping travels to target and back from target, so you must divide by 2 for actual target distance.
  targetDistance1 = targetDistance1 * 160934.4;    //Convert miles to inches by multipling by 160934.4 (centi meters per mile)
}

void ultrasonicFun2()
{
  digitalWrite(trigPin2, LOW);          //Set trigger pin low
  delayMicroseconds(2000);              //Let signal settle
  digitalWrite(trigPin2, HIGH);         //Set trigPin high
  delayMicroseconds(15);                //Delay in high state
  digitalWrite(trigPin2, LOW);          //ping has now been sent
  delayMicroseconds(10);                //Delay in high state

  pingTime2 = pulseIn(echoPin2, HIGH);             //pingTime is presented in microceconds
  pingTime2 = pingTime2 / 1000000;                 //convert pingTime to seconds by dividing by 1000000 (microseconds in a second)
  pingTime2 = pingTime2 / 3600;                    //convert pingtime to hourse by dividing by 3600 (seconds in an hour)
  targetDistance2 = speedOfSound * pingTime2;      //This will be in miles, since speed of sound was miles per hour
  targetDistance2 = targetDistance2 / 2;           //Remember ping travels to target and back from target, so you must divide by 2 for actual target distance.
  targetDistance2 = targetDistance2 * 160934.4;    //Convert miles to inches by multipling by 160934.4 (centi meters per mile)
}

Try this:
void loop() {

RightSensor = SonarSensor(trigPin1, echoPin1);

LeftSensor = SonarSensor(trigPin2, echoPin2);

FrontSensor = SonarSensor(trigPin3, echoPin3);

Serial.print(LeftSensor);

Serial.print(” – “);

Serial.print(FrontSensor);

Serial.print(” – “);

Serial.println(RightSensor);

}

long SonarSensor(int trigPin,int echoPin)
{

digitalWrite(trigPin, LOW);

delayMicroseconds(2);

digitalWrite(trigPin, HIGH);

delayMicroseconds(10);

digitalWrite(trigPin, LOW);

duration = pulseIn(echoPin, HIGH);

distance = (duration/2) / 29.1;

return distance;

}

Some explanation would be great

As far as I understand, your code does not solve the OP problem... Can you just point out what issue this solves and why?


text:
Can't read two bytes through Serial.read - Arduino
I'm sending via Bluetooth with an Android App two bytes like this:
private void _sendCommand(byte command, byte arg)
{
    if (CONNECTED)
    {
        try
        {
            os.write(new byte[]{command, arg});
            os.flush();

        } catch (IOException e) {
            Log.e(TAG, "Error sending command: " + e.getMessage());

        }
    }
}

And this is the code I'm using to receive them with Arduino:
byte _instruction;
byte _arg;

void loop()
{
  while(Serial.available() < 2)
  {
    digitalWrite(LED_BUILTIN, HIGH);
  }

  digitalWrite(LED_BUILTIN, LOW);

  _instruction = Serial.read();
  _arg = Serial.read();
  Serial.flush();

  switch (_instruction)
  {

     ...

  }
}

I don't have any problems sending just one byte (modifying the code to receive just one), but I can't do the same with two bytes. It's always stuck in the while. Any idea of what I'm doing wrong?

EDIT: As ST2000 pointed out, there was a problem of syncronization, so this is the code working properly:
void loop()
{
  // Wait until instruction byte has been received.
  while (!Serial.available());
  // Instruction should be read. MSB is set to 1
  _instruction = (short) Serial.read();

  if (_instruction & 0x80)
  {
    // Wait until arg byte has been received.
    while (!Serial.available());
    // Read the argument.
    _arg = (short) Serial.read();

    switch (_instruction)
    {
      ...
    }
  }

  Serial.flush();
}

Thanks,

What test data are you using? Try sending printable bytes (ASCII) first.

@MikaelPatel I'm sending as first byte 0x50 and as second byte a value between 0 and 100.

Your code never gets out of the while loop ?

@AndreCourchesne No, it does not.

How was your source code when sending succesfully only one byte ?

Have tried just with a serial port (not bluetooth), using the serial monitor if it works ? Maybe just maybe it's not the receiving end that does not work but rather the transmit side.

I suggest you always pull data in (for example use: "while(Serial.available() == 0);") then process what you expect to be the command and data bytes.  In your code there is nothing to recover from the receiver going out of synchronization with the transmitter.  For all you know, the transmitter has sent the command byte then the data byte.  However, the receiver may have skipped a byte and thinks the data byte is the command byte and is eternally waiting for what it thinks should be the data byte.  Which, of course, will never come.

@st2000 That makes sense, but, how do I recover if I'm out of sync?

By uniquely identifying commands as opposed to data.  Some protocols sacrifice a bit.  For example you could set the most significant bit for commands and not set the most significant bit for data.  However, that does mean you can only send data in the range of 0 to 127.  And it does restrict you to only 128 commands.  If you need more, and want to stick to this "most significant bit" approach, you could break your data into chunks and only send 7 bits at a time.  The possibilities are many.  Use this one or make one up that fits your needs better.

Let us know if this works & I'll copy these comments to the answer section.

@st2000 Thanks, a range of 0 to 127 will do, and 128 commands are more than enough. I'll give it a try as soon as I can.

@st2000 Yes! It's working.

Thanks for following up.  This will make a good question / answer resource for anyone who is having a similar problem.

There may be a underlying problem with synchronizing the transmitter and receiver.  They both have to agree / know which is a command byte and which is a data byte.
In order to do this, some protocols sacrifice a bit. For example you could set the most significant bit for commands and not set the most significant bit for data. However, that does mean you can only send data in the range of 0 to 127. And it does restrict you to only 128 commands. If you need more, and want to stick to this "most significant bit" approach, you could break your data into chunks and only send 7 bits at a time. The possibilities are many. Use this one or make one up that fits your needs better.
In order to implement this approach, you will need to read and process each byte as it arrives.  You can not wait until you accumulate the expected number of bytes as this assume you are always in sync with the transmitter. Which may not be the case.


text:
ESP8266MOD does not respond to my Uno (Custom board) AT+RST command
This is my very first project with a Uno board and ESP module. I have some experience with 8051 uP. I'd like some guidance in addressing my issue.
Objective:
To connect ESP8266MOD to my wifi network and send a TCP message to my HOME_SERVER whenever required.
Hardware Module:
UNO (Induino R5 Arduino R3 USB Clone Board) --> level shifter  --> ESP8266MOD
As a first step, I am trying to send AT+RST command from the Uno to the connected ESP. But there is no response from the ESP. However, I am able to notice a LED blink on the ESP, whenever there is TXD operation in my Uno.
Hardware Connection:
UNO - Uses USB Power supply from laptop
ESP8266MOD- Uses 3 1.5V AA Batteries

                 ||
    UNO PINS       TXD      RXD     5V GND
                    ||      ||      ||
    LEVELSHIFTER     >>RXI   <<TXO  HV,GND
                        ||      ||
                    RXO<<    TXI>>  LV,GND
                    ||      ||      ||
    ESP8266MOD      RXD     TXD     3.3V,GND

ESP8266MOD Settings:
    CH_PD ->> 3.3V
    GPIO2 ->> 3.3V
    GPIO0 ->> GND
    GPIO15->> GND

Uno Code:
#include <SoftwareSerial.h>

const byte rxPin = 2; // Wire this to Tx Pin of ESP8266
const byte txPin = 3; // Wire this to Rx Pin of ESP8266

// We'll use a software serial interface to connect to ESP8266
SoftwareSerial ESP8266 (rxPin, txPin);

void setup() {
  Serial.begin(9600);
  ESP8266.begin(9600); // Change this to the baudrate used by ESP8266
  delay(3000); // Let the module self-initialize
}

void loop() {
  Serial.println("Sending an AT command...");
  delay(3000);
  ESP8266.println("AT+RST");
  delay(30);
  String response = "";
  while(ESP8266.available()) {
    char c = ESP8266.read();
    response+=c;
  }
  if(response != "") {
    Serial.println(response);
  } else {
    Serial.println("Empty\r\n");
  }
}

Output Video: Output video view
  -->

That yellow PCB, is it possible that it already have the level shift on it ?

@AndreCourchesne No, The RX and TX are directly taken from pinout. I doubt that

Then maybe you have rx connected to rx (same for tx). I would use a continuity tester to make sure of the wirring.

@AndreCourchesne    I interchanged pin from in ESP end already. still no luck. However, with existing connection when there is TX from UNO, I am able to see LED  blink in ESP.

Then the next step to me would be oscilloscope or logic analyser.

@AndreCourchesne : What about my connections. Is it correct ??

Very hard to tell, not sure I understand the way you wrote it. If you could make a drawing would be better. Try using Fritzing to do it.

Couple of ideas... Are all of your GND tied together ? They need to.
What powered your ESP8266 3.3v ? You mention 3x AA batteries, but that totals 4.5v, not 3.3v...

@AndreCourchesne :: Started from step 0 now.. Tried loopback in UNO it worked. But, loopback from level shifter not working. (https://i.stack.imgur.com/qACko.jpg)

good move. I don't know that level shifter, you got some documentation or the schematic of it ?

@AndreCourchesne : http://www.amazon.in/Generic-Channel-Converter-Bi-Directional-Module/dp/B011ECG2MM?tag=googinhydr18418-21&tag=googinkenshoo-21&ascsubtag=d2f6ed02-1c9d-4c8e-8474-e94a6cb1c3f1 -- This is product info..IS it the right one to use here. my intention to use it here is for converting 232 (5v) to 3.3v (ESP)

Found the original maker of that level shifter (https://www.eprolabs.com/product/logic-level-converter/)
So your diagram looks good as far as how I interpret it. Where do you take your 3.3v from ? And the converter has 2 converter slots maybe one is detective, have you tried the other one ?

@AndreCourchesne : 3.3 V is separate and given from ESP module. I physically checked voltage in multi meter and seems normal

If it is a new ESP module, your problem is quite likely a baud rate mismatch, since you are seeing an LED response but getting no reply.
The last batch of ESP-01s I received defaulted to 115200 baud, but that is too fast for SoftwareSerial (SS). You'll need to change it to 9600. My answer to a related question describes one way to change it.
You could also change it with SS. You'd have to start off SS at 115200 baud, which will usually transmit OK; just ignore the apparent garbage that comes back. Then change SS's baud rate to 9600 to match, and you should have solid communication.
These are the three commands you need to send the ESP to accomplish the change:
AT                             # ESP should respond "OK"
AT+RST                         # Resets the ESP
AT+UART_DEF=9600,8,1,0,0       # Sets ESP UART: 9600,N,8,1,no flow ctl

Note: Your module might have been preset to some other rate than 115200, in which case you'll have to try various rates until you can get an intelligible reply. Once you do, set the default rate to 9600.


text:
LCD5110 - How to make Direct Draw via 2D-array of boolean?
How to draw 2D-array directly on LCD 5110 (PCD8544)?
I have tried libraries like AdaFruit and several others.
But I need draw there via pixel 2D-array, something like this:
bool picture[48][84] = {
 {0,1,0,0, ... to 84 elements},
 {1,0,1,0,0, ...},
 ... to 48 elements
};

I haven't used charset table or geometry figures drawing library functions. Simplest and smallest drawing by pixel - 0 - not draw, 1 - draw pixel.
The "picture bitmap" will generate on the mini-pc board via Python and send to Arduino, which will draw it as "video card".
What is the simplest way to draw pixel in any site of the display without using powerful libraries?
Something about this:
// Send boolean bitmap 48x84 to LCD 5110
// Rows
for (int i=0; i<48; i++) {
 // Columns
 for (int j=0; j<84; j++) {
  // PIN 5 is Din on the 5110 module
  digitalWrite(5, picture[i][j]);
 }
}

Have you successfully drawn anything on the display? Could you post the code you used to do that, please?

No problem with this. Please see the Cosa PCD8544 driver for inspiration; https://github.com/mikaelpatel/Cosa/blob/master/libraries/PCD8544/PCD8544.cpp#L150 and example sketch https://github.com/mikaelpatel/Cosa/blob/master/libraries/PCD8544/examples/CosaPCD8544temp/CosaPCD8544temp.ino

Hi all!
Thanks for your answers!
Yep, drawing geometry and texts is OK.
I think, I need use symbol-sites 8x8 pixels as "small displays" and send there fragments of picture / count of symbol-sites. It like small 506-bytes one-dimension array, not 4096 pixels matrix.

For a start the Arduino Uno is incapable of storing that array in RAM. You're using twice as much memory for that array as the Arduino has in total. You will have to place it in PROGMEM and use the right functions to access it.
Secondly, you have to use a special library to control the display properly. That library will contain functions to draw on the screen. So your function to draw it would look something (though not exactly) like this:
const bool picture[] PROGMEM = {
    1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0,
    ... etc ... ... 4032 numbers in total ...
};

for (int i=0; i<48; i++) {
    for (int j=0; j<84; j++) {
        lcd.setPixel(j, i, pgm_read_byte_near(picture + (i * 84 + j));
    }
}

Refer to the manual for the library for the actual function to run and how to configure and set up the LCD screen.

bool seems like a waste of memory. And the device has byte level transfer to the display memory. The memory requirements for an off-screen bitmap is only 48*84/8 = 504 bytes.

// PIN 5 is Din on the 5110 module
digitalWrite(5, picture[i][j]);

with that kind of code, I would suggest that you spend a little bit more time on understanding the libraries you are trying to use, or the datasheet if you aren't using any libraries and ask more directed questions.
embedded engineering is one that ties software with hardware and it is not possible for you to understand software without understanding, very well, the hardware first.


text:
avrdude: stk500_recv(): programmer is not responding - OSX10.11
I'm getting the following error with a genuine Arduino Uno on Mac OSX10.11 El Capitan when uploading to it (the green light is on, the orange light flashes intermittently while attempting to upload). Here's the error:
avrdude: stk500_recv(): programmer is not responding

I've tried all the solutions I can find. I've selected the correct port and board. I've tried pressing the reset button before uploading. I've tried different USB cables. I've tried unplugging and replugging everything. I've read this: http://arduino.cc/en/Guide/Howto .
I tried all these solutions here: https://stackoverflow.com/questions/23993111/mac-uno-avrdude-stk500-recv-programmer-is-not-responding
I tried the FTDI fix, (but not sure if was actually able to disable the mac drivers, or which drivers are now running, the example I tried is for for OSX 10.10 Here). I ran into the following issue in the Terminal:
Mac-Pro:~ m$ cd /System/Library/Extensions/IOUSBFamily.kext/Contents/PlugIns
Mac-Pro:PlugIns m$ sudo mv AppleUSBFTDI.kext AppleUSBFTDI.disabled
mv: rename AppleUSBFTDI.kext to AppleUSBFTDI.disabled: No such file or directory

I don't get why it says No such file or directory because AppleUSBFTDI.kext definitely exists as a package in the Extensions folder, but I guess it's talking about another file named that in the plugins folder? Confusing ... Was this moved in OSX 10.11 and should I rename this package in the Extensions folder?
I did download and install the old FTDI drivers, but I don't know if they're actually the ones working right now? How do I clarify that?
Any ideas how to get this working?
I also tried on an old Mac Laptop 10.6.8 - Snow Leopard, and had the same issue :(

Has this ever worked?
Can you use avrdude and hit the target?
There is a terminal mode in avrdude you can also use.  At least this would help you determine what is working.
Sounds like a configuration issue.  If you have the ability to 'follow the tail' (tail -f ) I'm assuming that you have 'like' tools we have in Linux like lsusb to assist?
You can ensure yourself that if it says it isn't found, it's not finding it, so it's not wherever it's looking. :)

It had never worked.  I think it was just a bad one, I got a new one, works perfectly :D

I had this problem for some time and what I did was I deleted the Arduino IDE and reinstalled it again and it worked. Thanks!

Nothing I tried could get it to work. I took it back on the hunch it was a bad one, that something was just not working right on it. And got a new one directly from the Arduino people. The new one works just fine! Problem solved :D


text:
How to create a heart rate detection system that uses a chest strap?
I want to create a system that uses a chest strap from available Bluetooth-based heart rate monitoring systems. The straps seem very convenient compared to available Arduino pulse detection systems that use electrode pads (which must be placed individually and that wear out), or infrared sensors, which are cumbersome.
I find the Bluetooth systems not super reliable and would like to use the strap with a wired Arduino based system. Is it possible and if so how?

You're asking how to create a wired connection to an unspecified device not designed for it. You'll at very least need to specify the device.

You'll need a data-sheet (or other spec) for the sensors in the particular strap, and from that, buld an interface to your Arduino. It will probably involve supplying power to the sensor, amplifying the sensor output, noise rejection (low-pass filtering might be enough), detecting the signal exceeding a threshold, and outputing a level or a pulse when it does.

I can manage detecting a pulse from a signal. The strap is from a Polar H7. The battery is a CR 2025 which is 3V. Can the Arduino 3.3V supply power to the sensor? How could the output be amplified and the noise reduced? Is this post, http://forum.arduino.cc/index.php?topic=317073.0, relevent?

I think that the correct answer is yes/no. Theoretically you can, if you have the appropriate knowledge. Dismantle the sensor, and probably you will find that there is a battery, a circuit and some wires going to some electrodes. Detach the wires from the circuit, and use them exactly like you would use some standard electrodes. But when I built a small ECG I bought the electrode pads because other materials have a very high contact resistance, and so I think that the main problem with your band is the electrodes (consequently even with an arduino you will get poor performances)


text:
How to set up a long press with something other than a button?
I wrote a program for a night light. There are 4 modes:

on,
adjustable brightness,
timer,
off.

For input, instead of using a button, I am using a distance sensor. Once a certain distance is read (eg. when passing your hand over the distance sensor) it changes to the next mode.
For the adjustable brightness mode it reads the distance sensor and is mapped to a PWM. The output pin is connected to a MOSFET which is switching a 12 volt LED.
This seems a slow way to cycle thru the system. I would like instead, if the user waved their hand over the sensor, it would turn on or off. However, if the user waited for 3 seconds with their hand over the sensor it would enable a dimmable mode. I'm not concerned about the timer function anymore and will be removing it.
All the code is already there except I need help writing a function that will keep track of how long its been reading a certain distance. Let's say for instance if the sensor reads a distance between 1 inch to 3 inches for 3 seconds it will then go into the dimmable mode. If it's under that then it will only toggle on/off. If the hand remains longer then 3 seconds it will also trigger the dimmable mode.
//----------------------------------------------------------
// USING A DISTANCE SENSOR TO CYCLE THRU DIFFERENT MODE
// FOR AN LED NIGHT LIGHT
// vonderasche
//----------------------------------------------------------

// declares library for distance sensor
#include <NewPing.h>
// constants
#define TRIGGER_PIN  12
#define ECHO_PIN     13
#define MAX_DISTANCE 200
const unsigned long onTime = 5000;
const unsigned long onTimer = 1200000;

int state = 1;

// declares NewPing object
NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE);

void setup() {
    Serial.begin(9600);
}

void loop() {
    delay(50);
    // take distances reading
    int distance = sonar.ping_in();
    static enum { ON, ADJUST, TIMER } state;

    // if distance range is between certain values switch the state
    if (distance > 1 && distance < 3) {
        switch(state) {
        case ON:
          {
            // turns LEDs on
            Serial.println("ON");
            analogWrite(3, 255);
            analogWrite(5, 255);
            state = ADJUST;
            delay(1000);
          }
          break;
        case ADJUST:
          {
            // allows user to set brightness based on hand distance to sensor
            Serial.println("Adjusting Brightness");
            int distance2 = 0;
            int mappedBrightness = 0;
            unsigned long previousMillis = millis();
            unsigned long currentMillis = millis();

            // timer for setting brightness
            while ((currentMillis - previousMillis) < onTime) {
                int distance2 = sonar.ping_in();
                if (distance2 >= 1 && distance2 <= 6) {
                    mappedBrightness = map(distance2, 0, 6, 13, 255);
                    analogWrite(3, mappedBrightness);
                    analogWrite(5, mappedBrightness);
                }
                currentMillis = millis();
            }
            Serial.print("Mapped Brightness = ");
            Serial.println(mappedBrightness);
            delay(1000);
            state = TIMER;
          }
          break;

        case TIMER:
          {
            Serial.println("TIMER - 20 MINS");
            // variable declaration
            unsigned long ontime = 50;
            unsigned long previousMillis = millis();
            unsigned long currentMillis = millis();

            // dims leds to 25 percent
            analogWrite(3, 64);
            analogWrite(5, 64);
            delay(1000);
            // timer for leds
            while ((currentMillis - previousMillis) < onTimer) {
                int distance2 = sonar.ping_in();
                //breaks timer if hand swipe
                if (distance2 >= 1 && distance2 <= 4) {
                    break;
                }
                currentMillis = millis();
            }
            // turn off leds - either hand swipe happened or timer is up
            Serial.println("Turn off LEDs.");
            analogWrite(3, 0);
            analogWrite(5, 0);
            delay(1000);
            state = ON;
          }
          break;
        }
    }
}

Is the dimmer mode used to the case ADJUST: state or planned for another state ?

The dim mode works. Right now the program progresses from case one to case four in sequence. I would rather have on/off or if the hand is held over the sensor long enough the dim mode is triggered

So if delay < 3s ==> switch between ON & OFF state, otherwise ==> go to the ADJUST state ? But is the brightness controlled by the extra delay instead of distance2 ?  And what about the TIMER state ?

This is not too different from the long press of a button. Lets consider the code to detect a long button press of greater than 3 seconds.
buttonState = digitalRead(PIN1);

if (buttonstate == HIGH)
{
    if ((currentMillis - previousMillis) > THREE_SECONDS)
    {
        // Put your code here
    }
}
else  // ie. buttonState == LOW
{
    previousMillis = currentMillis;
}

OK, so the code could be optimized. However, it shows the code for a long button press and hopefully its easy to understand for any newbies out there. The code above reads the button state and if it is HIGH (ie. pressed), it will then check to see if the timer has run for more than 3 seconds. However, if the button is released, the timer resets.
Now lets consider the code for a distance sensor:
int distance = sonar.ping_in();

if (distance >= 1 && distance <= 3)
{
    if ((currentMillis - previousMillis) > THREE_SECONDS)
    {
        // Put your code here
    }
}
else  // ie. outside of the range
{
    previousMillis = currentMillis;
}

You will notice that only the first two lines change. I hope this helps!!


text:
const int re-declaration - memory leakage
I am re-declaring a const int variable a few times in a switch-case statement of a function as shown following:
void functionB(type param1, type param2, ..., const int paramConstInt = 100);

void setup() {
    ...
}

void loop() {
    ...
    functionA();
}

void functionA() {
    ...
    switch(var) {
        case 0: {
            const int paramConstInt = 200;
            ...
            functionB(param1, param2,..., paramConstInt);
            break;
        }
        case 1: {
            const int paramConstInt = 300;
            ...
            functionB(param1, param2,..., paramConstInt);
            break;
        }
        case 2: {
            functionB(param1, param2,...);
            ...
            break;
        }
        ...
        default:
            // if nothing else matches, do the default
            // default is optional
            break;
        }

}

void functionB(type param1, type param2,..., const int paramConstInt) {
    ...
}

Does standard C++ allow for it? I am asking so because, if I try to change one of the paramConstInt inside a switch case to 1000 or so I have a strange behaviour similar to that given by a memory leakage. I think anybody willing to replicate this oddity can do it and report.
If const int is replaced by just int, the problem seems to disappear.

Are you using paramConstInt somewhere else ? If now why not simply call functionB(param1, param2,..., XYZ); where XYZ is the value. For example functionB(param1, param2,..., 300); ?

yes, using paramConstInt in the switch-case block as well before passing it as an argument; so the pseudocode above should more precisely be: const int paramConstInt = 200; ...; functionB(param1, param2,..., paramConstInt);

Then your const is not a constant, it's variable. I suggest defining it as such.

What you describe, along with the posted code, has no issue in C++ whatsoever. If you have a strange behavior when setting paramConstInt to 1000, then this is probably due to what functionB does with that argument value.

You have to show us the code of functionB to check what could explain that odd behavior.

The core of the matter is that by changing "const int" to "int", everything runs smoothly. I cannot say that functionB is clear but the matter around "const int" sounds strange to me and I wanted to let you know - that is the main reason why I posted it here.

Does changing const int to int in just the variable declaration, or in both the variable and functionB fix it?

Also, don't you need the paramConstInt to be before the variadic placeholder?

I just changed "const int paramConstInt = 200;" to "int paramConstInt = 200;" - for example - and it fixed it.

"before the variadic placeholder" ?

I had to look that up, too. :) A variadic function is one that takes a variable number of arguments. I assumed your use of , ...,  was meant to imply "maybe some other arguments here, how many of them isn't important to the example", and not "this function takes a variable # of arguments"?

yes, I meant "maybe some other arguments here, how many of them isn't important to the example"

Sorry for alerting the community for one of my faults. I'll try to explain what happened in my code and why "const int" made a difference against just "int".
In my code, functionA() is not being called by loop() as sketched above but it is actually repeatedly called by a third function, say functionAcaller(), which keeps control while in a millis-interval.
Moreover, functionB being called by functionA in turn, has several parameters among which an array vital to the correct functioning of the program, name it MAIN_ARRAY. I didn't notice up to the time I started debugging the "const int" issue that MAIN_ARRAY is local and declared (not initialized) within each switch case (same array size for all switch cases) though every time I enter again one of the switch-cases I actually need to change the values the array contained in the previous run. In spite of the fact that I (re)declared MAIN_ARRAY every time I entered functionA() switch-cases, things were fine since the previous values were not probably cleared by the micro. Well, there was in reality a problem given by "const int paramConstInt". When I set it too big, the program lagged. I guess it had to do with its default value being only 100. Another problem was possibly the order of (re)declaration: whether the first variable being (re)declared was MAIN_ARRAY or const int paramConstInt. Anyway, even when MAIN_ARRAY was (re)declared as first thing once back to functionA() switch-cases, a too big const int paramConstInt caused problems while int alone of the same value was just fine. Sorry again for not having delved into this issue more deeply in advance but since everything was all right except for "const int" I really thought that was the problem.

Once inside the scope of a switch-case, the first memory allocations carried out are for statics and constants. If there are any, any allocation from a previous run must be shuffled. However, I still don't understand why a small-value const int was just fine.

Essentially the poster was (unknowingly) relying on the old contents of then retracted stack still being there when the stack subsequently grew back into that region.  That's an extremely unsafe assumption easily broken by minor code changes or differences in compiler behavior.  It's possible the small value was being optimized out and directly inserted where needed, while the large value may have required stack manipulation.  One would have to read the disassembled output of the compiler to know; of course the only real answer is not to violate the contract of the programming model!


text:
List of connected clients to server
I have a server on my arduino (WiFi) and want to save the clients that connect, so that I can send to them (to each separately) data later.
Is the best data structure a linked list? How can I see if this client connected already (if there is already a connection to this ip) to avoid doubles? How can I detect when they disconnect in order to delete them?
Of course, I read the ref; but I cannot find the answers there.
Here is my minimal example (The maximum number of simultaneous connections is 5):
EDIT Keep in mind, that I just want to have a simple connection using the WiFiClient/ WiFiServer class and not a HTTP-Webserver
#include <WiFi.h>

WiFiServer server(23);
void setup() {
  server.begin();
}

void loop() {
  WiFiClient client = server.available();

  if (client) {
    //if not seen yet, add to a linked list (?)
  }
}

When you say "if this client connected already", do you mean whether there is already an active connection from the same IP address?

What is the maximum number of simultaneous connections you need to support?

@MarkSmith see edits

The WiFiClient.h header and WifiClient.cpp source files are useful for reference.

Is the best data structure a linked list?

Probably not here.  Possibly not ever.  It's a load of effort to implement, and won't give you any benefit.  Just create an array of them:
WiFiClient clients[5];

Then perhaps something like
WiFiClient newClient = server.available();
if (newClient) {
    // TODO: Check whether we have an existing connection from this IP
    // TODO: Get the first 'free' array index
    clients[firstFree] = newClient;
}

How can I see if this client connected already (if there is already a connection to this ip) to avoid doubles?

Get the remote IP address of the new client
IPAddress = newClient.remoteIP();

Do the same with all the connected clients in your array* and compare them.  If you find a match, drop the connection
newClient.disconnect();

and, probably, don't put it in the array.

How can I detect when they disconnect in order to delete them?

if (client[i].connected())

Lastly, how do we keep track of which items in our array are current active connections, and which aren't (either not yet used, or already disconnected).  You could do this several ways.  One would be to iterate through the array, checking whether the item is valid and connected:
// Returns -1 if no free slots
int firstFree() {
    for(int i=0 ; i<5 ; ++i) {
        if(!clients[i] || !clients[i].connected()) return i;
    }
    return -1;
}

All code untested so you may find typos, but I believe it's basically correct.

http is connection less. And simply putting a comment in the code is not a very good idea!

+1 Only correct answer I see here.

I have a server on my arduino (WiFi) and want to save the clients that connect, so that I can send to them (to each separately) data later.

The question (and some of the answers) seem to misunderstand how HTTP works. I know how it works (at least to an extent) as I have written server scripts in Lua, as well as C++ for the Arduino.
As I mention in my page about an Arduino HTTP server when the client initiates a request it sends an HTTP header along these lines:
POST /forum/showpost.php?id=12345&page=2 HTTP/1.1
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:39.0)
Host: www.example.com
Cookie: foo=bar;
Accept-Language: en, mi

action=save&user_id=1234

Breaking those parts down you get this:

Once the client has sent the request it awaits (on the same connection) for the server to respond. The response may look something like this:
HTTP/1.1 200 OK
Content-Type: text/html
Connection: close
Server: HTTPserver/1.0.0 (Arduino)

<!DOCTYPE html>
<html>

<head>
<title>Arduino test</title>
</head>

<body>
<h1> My heading </h1>
<p>Some text
</body>
</html>

Notice the blank line between the HTTP header and the actual file data (the HTML data).

Under HTTP 1.1 the server can request that the connection keep open the connection by replacing:
Connection: close

by:
Connection: keep-alive

All this means is that the client is still connected and can now request other stuff (for example an image from an <img> tag). It does that by sending another HTTP header and then getting another response. It doesn't keep the connection open just so that the server can randomly send other stuff in the future.
Note: - the default under HTTP 1.1 is for the connections to be persistent.

... so that I can send to them (to each separately) data later.

You don't "send data later", that's not how it works. The client may request data later.

The standard way of keeping track of clients which are doing stuff (like filling in a series of forms) is to use cookies - that is what they are for. The server sends a cookie, the client remembers it, and sends it back with the next request. The cookie identifiers that it is the same client as before, and what it was doing. For example, a cookie might contain a token to indicate that you have logged in.

Good explanation of HTTP. Note however that the OP doesn't mention using HTTP ☺. It's perfectly valid to have a normal TCP socket connection open and for data to trickle down it as and when the server feels like it.

Good point. Still, if you have a number of connections from TCP sockets, surely you know what they are already?

I'm not sure I understand what you mean.

+1 I think you meant to say Under HTTP 1.0... since HTTP 1.1 connections are persistent by default.

Ah, OK. But you can still choose whether or not they are persistent. And judging by what I read some servers time out fairly quickly (15 seconds).

@MarkSmith - well, if you are on the phone to Aunt Ruth, you know you are talking to her, right? You don't need to write it down on a list. So if you have a number of connections open, they are in a list somewhere already, otherwise you couldn't be using them.

I still don't understand what that's got to do with anything here, but perhaps it doesn't matter :-)

@MarkSmith - the question was How can I see if this client connected already - well, if the client is connected they are in the list of connected clients. To answer the other part of the question a simple array would probably do, as you can only have about 4 connections on Ethernet shields anyway.


text:
Floating pins: digitalRead returns always high or always low
I was trying to see whether my board operates as expected with random readings on floating pins. Oddly it does not. The following code produces all HIGH readings:
#define PIN_MISO 12

void setup() {
  pinMode(PIN_MISO, INPUT);
  Serial.begin(9600);
}

void loop() {
  uint16_t data = 0;
  Serial.print("MISO digitalRead: ");
  data = digitalRead(PIN_MISO);
  Serial.println(data, BIN);
  delay(300);
}

MISO digitalRead: 1
MISO digitalRead: 1
MISO digitalRead: 1
MISO digitalRead: 1
MISO digitalRead: 1
MISO digitalRead: 1
MISO digitalRead: 1
MISO digitalRead: 1
MISO digitalRead: 1
MISO digitalRead: 1
MISO digitalRead: 1
MISO digitalRead: 1
MISO digitalRead: 1
MISO digitalRead: 1
MISO digitalRead: 1
MISO digitalRead: 1
MISO digitalRead: 1
MISO digitalRead: 1
MISO digitalRead: 1
MISO digitalRead: 1
MISO digitalRead: 1
MISO digitalRead: 1
MISO digitalRead: 1
MISO digitalRead: 1
MISO digitalRead: 1
MISO digitalRead: 1
MISO digitalRead: 1
MISO digitalRead: 1
MISO digitalRead: 1
MISO digitalRead: 1

I tried grounding pin 12 and after a few seconds the readings all came back LOW as expected. However leaving it floating produces all HIGH instead of random readings.
I tried the same program for pins 3 and then A3 with more weird output: all LOW.
What am I missing here?

If it's floating, then anything can influence the reading. Humidity, temperature, nearby pins/traces, a human body nearby (try placing your finger near the pin), manufacturing differences, nearby radio sources (WiFi, BT). But in the end of the day, it doesn't matter, as you should rely on a certain value from floating pins. Just add a pull-up or pull-down resistor.

You are missing longer wires, touch or something noisy nearby (like DC motor)

Why you expect to behave randomly every read?
According to Arduino docs, you should be using the random function to get random numbers, of course this is a pseudo random generator which you have to randomSeed, for this you could use an analogRead to a floating input.

Floating means it would generate any value. This could be a result of innumerable factors and it is HIGH in this case! you cannot expect anything other than a HIGH or LOW.
Think of it this way-
It's fluctuating in a range of about 900-1000 but the range is still very close to 1023 hence it results in a HIGH.
Some other time it may be near the lower values then it would show LOW.

While an intermediate level is possible, it may be more probable that the actual voltage is a definite legal "high" but that there is nothing holding it there with any authority - only the vaguest of leakage current, easily overcome by any other driver or source of charge.

Change:
pinMode(PIN_MISO, INPUT);

to
pinMode(PIN_MISO, INPUT_PULLUP);

This will enable the internal 20k pull-up and you should then always read HIGH is the pin is floating.
Using INPUT does not enable the internal pull-up (Ref: https://www.arduino.cc/en/Reference/pinMode)

This does not answer the original question!

Actually, this answer did work for me, the implication being, "you're doing something that's undefined, so there's no point in speculating on what you might read; instead do something like this if you're going to be reading floating pins."


text:
Do I need a transistor if my relay has an optocoupler?
I'm looking to use this relay  with my arduino. It has an optocoupler and correct me if I'm wrong but this should prevent any back EMF from affecting my arduino. Do I still need to use a transistor?

I'm not sure why everyone wants to close this question as off-topic. But driving relays (especially relay boards) with an Arduino is, in my opinion very on topic.

I'm voting to close this for inactivity. Since it has been two weeks after a good answer and we haven't heard anything of the (relatively new) person who asked the question. So the question is likely to be abandoned.

That isn't just a relay you are linking to. That's an entire board that, among others, contains a relay (blue box). This board already has a transistor to drive the coil inside the relay. It also has a diode to handle back EMF.
It even has a opto-coupler, thought that isn't that useful as in most cases both sides of the opto-coupler are powered by the same 5V coming from the arduino.

Gerben is right. That is a complete board, not a relay. I have used some of these and they do not require a transistor to drive them (although you could use one if power output from the ports are a concern).
I beg to differ from Gerben, as the optocoupler isolates the pin from the driving circuit (even if it does not isolate the regulator) it still retains much of its safety characteristics.


text:
matrix buttons 8x8
Hi I have 8 buttons on my Arduino uno and I want to create a matrix 8x8 and give each button a row and a column respectively it is not a keypad just 8 buttons each button have a row  and a column  ex:                   y
                                                          x(0,0,0,0,0,0,0,1)
                                                            1,0,0,0,0,0,0,0
                                                              .....
to compare it with other values on my visual studio c# , I can't find anything about this .
anyone can help ?

... ... ... um... what?

sorry it's not very clear / I want to create a 8x8 matrix

An 8x8 matrix has, by its simple definition, 64 buttons. Do you have 64 buttons?

And I have 8 push buttons for each button I want to assign a row and a culomn like row[1]column[1] to push button 1

You have "8 buttons for each button" - you aren't making any sense whatsoever.

An 8x8 matrix has 64 buttons. That's what an 8x8 matrix is. The reason why you can't find an answer to your problem whilst searching is simply because you do not know what your problem is. I think you need to rewind and think about what you want to achieve, not how you think you want to go about achieving it.

@Majenko There's punctuation missing. This is how I think he means it to read: "I have 8 push buttons. For each button I want to assign a row and a column."  The question still doesn't make sense, but at least that sentence does.

I have a windows form application that have 8x8 labels each label have an x and y

Does this do what you want?
int col;
int row;

int buttonPressed = readButtons();  // <-- You implement this!

switch (buttonPressed) {
    case 1:
       row = 7;
       col = 3;
       break;
    case 2:
       row = 1;
       col = 2;
       break;
    case 3:
       row = 0;
       col = 4;
       break;
    // and so on
}

something like that , when i press the button if it have the same value of x and y of the labels the label will change color , hhow can i post a pic to clarfy

The code above lets you specify an x and y (actually row and col but you can rename them) value associated with each button.  To compare them with other numbers -- use if (row == someOtherRow) and so on. If you want someone to plumb this into some other code you have, you'll need to post the code -- we can't guess it.

is there a way to discuss this with you by email? i'm getting a lot off errors here

Break the problem down into little pieces and get each piece working one at a time. If you're getting compiler errors, strip out all the code, and just put your little piece in, and get that working. Compare it to examples (Google...). If you can't work out a particular thing, you can post a question here (Arduino specific) or in StackOverflow (C++ questions).  If it's related to code in my answer, ask here :)

I can't add a picture here ?

i added a question please check it

authors: Вихор Дмитрий


text:
Having Arduino read a video game screen
I want to connect my Arduino to my tv screen while playing a playstation/XBox game. When a certain screen comes up (like say when you die the same screen pops up) then I want Arduino to catch that and then trigger another device on and off. How might I be able to trigger something by having arduino read the screen then trigger something on and off?

This is image decoding (decoding the HDMI or composite output) there is no way an Arduino is powerfull enough to analyze the image in a viable amount of time. Plus the output of HDMI (or worst composite) is rendered so there would need to be interpolation of the colors, paterns,...
You need something WAY more powerfull than a 16MHz uController for this kind of work.

Not a chance. The Arduino doesn't even have a fraction of the processing power needed, and only about 0.0000000001% of the memory you would need. Instead you need to use something more realistic. Maybe a Raspberry Pi with a video capture dongle and OpenCV?

There's actually not a lot of processing that needs to be done to recognize a steady computer-generated image (or a distinguishing part of one).  But you do need some ability sample (even if only one detail at a time) with an analog bandwidth comparable to the video one, and an ATmega can't do that at the resolution of a modern game system.  So at the least this would require some clever external circuitry that could be basically told "give me the value of the pixel at X, Y in the next frame" and then run that many times to check details until you've decided the game is sitting on that screen.

@EvanB, You can help improve the site who's objective is to accumulate good questions and answers by either accepting answers that work for you or refining your question (edit it) in hopes of getting a better answer.

Most Arduino platforms contain a very low power embedded processor.  As such it is very unlikely such a device will decode an NTSC or PAL signal let alone modern digitally compressed video.
Instead consider using a light sensor attached to your monitor.  This is more in line with what, for instance, the Arduino Uno is capable of.  If you can identify a spot on the monitor that will only change to a certain brightness at the conclusion of a game, you could look for that brightness level using a light sensor attached to the monitor and connected to an Arduino.
Here is a tutorial about using a light sensor with an Arduino.  Most of the circuit is for the display of which you need not bother with.


text:
Multiple tones with one piezo buzzer
I have figured out how to make a piezo buzzer play two tones at once with analogWrite() and tone() but how would I make an actual song by playing both bass and treble, such as this one. Here is the circuit I had to do it:

and here is the code I had to do it:
int buzzer1 = 9;
int buzzer2 = 10;

void setup() {
  pinMode(buzzer1, OUTPUT);
  pinMode(buzzer2, OUTPUT);
}

void loop() {
  analogWrite(buzzer1, 100);
  tone(buzzer2, 262);
}

That circuit looks dangerous to me: you have two outputs shorted together, and each will be driving the other. It will damage the outputs, if it hasn't already. You need some sort of voltage adder I think.

First of all - You can drain max 20mA via pin, when one of the pins is HIGH and the other LOW, there is 5V between them, so there should be at least 250 Ohm resistor placed there, if you do not want damage your Arduino. I sugest add, to each of the red wires, at least a 200 Ohm resistor (to be safe).
For playing melody you have to save it somewhere, probabely easiest way is in arrays, and then play it note by note at regular intervals.
something like this (but insert your notes and set the length correctly):
int num_tones=6;
int tones1[] = {100,200,400,200,100,50};
int tones2[] = {262,131,131,262,131,524};

void loop() {
  for (int i=0;i<num_tones;i++){
    analogWrite(buzzer1, tones1[i]);
    tone(buzzer2,tones2[i]);
    delay(250);
  }
}

@Amorris: thanks for edit, I am not native speaker (not good speaker too)

I completed the following project https://github.com/linhartr22/count
Plays PWM files on Arduino through piezo speaker.
Most of the results came from the following page:
http://highlowtech.org/?p=1963
I'm using the https://github.com/damellis/PCM/zipball/master library mentioned there. count.ino is my sample sketch. As the web site mentions the audio comes out on Digital I/O pin 11. I've tested with both a piezo buzzer and a 4 ohm speaker. I'm really impressed. It does mess with some of the PWM timers so this may not be suitable for all applications.
I used Audacity to convert the sample wave files I was provided into PWM. The .h files are included in this repo.
The number of notes you can hold on the Arduino will depend on the size of the wave samples. If you need more notes, it might be possible to extend this with an SD card reader or other form of memory. It wasn't required for my project.