text:
Hard-resetting an arduino
I need to hard reset (or seriously breathe life into) a stuck Arduino clone (Sunfounder UNO) which doesn't get recognized by Windows (error 43) after installing the wrong sketch. I am using the latest Arduino toolset and, before today, the setup was functional.
The problem is probably that I am writing to the serial in the setup() section like this:
void setup() {
  pinMode(a0, OUTPUT);
  pinMode(a1, OUTPUT);
  pinMode(a2, OUTPUT);
  pinMode(b1, OUTPUT);
  pinMode(m0, OUTPUT);
  pinMode(m1, OUTPUT);
  pinMode(m2, OUTPUT);
  pinMode(OK, OUTPUT);
  pinMode(KO, OUTPUT);

  pinMode(carry, INPUT);
  pinMode(result, INPUT);
  delay(1000);

  Serial.begin(9600);
  Serial.write("Arduino Tester v. 0.1\n");
}

Arduino seems to be running the code. The problem is that Windows doesn't recognize it and doesn't set up a COM port for it.
So: i'd like to nuke it and restart from scratch.
How is this done?

What kind of Arduino clone?  What USB interface does it use?

@Majenko updated the question

The word "clone" immediately rings alarm bells.
Firstly, for a "normal" Arduino (like an Uno, etc) the sketch cannot influence whether Windows detects the board or not.  All that is handled by a completely separate chip.
A lot of the cheap clones these days are coming out of China with a really really cheap USB serial adapter chip.  These barely work at the best of times.  Looking at the pictures I have found of your clone (the manufacturer's site is considerably lacking in any information whatsoever) it doesn't look like it's one of those chips, but one never can tell.
If they have followed the reference designs for the Arduino then it will be an Atmel ATMega32U4 (IIRC) chip that deals with the interface to the computer.  That has firmware of its own on it, and if that has become corrupted (very unlikely) or damaged (possible) then it could cause it to not be recognised.  If that is the case the in the former instance (corrupted) you will need to replace the firmware on it. For that you will need either a hardware ICSP programmer or another Arduino.  In the latter instance you're stuffed, since you would need to replace the chip.
As I say that is unlikely.
Instead your problem is most likely actually with either Windows or the USB cable.  You may need to remove and reinstall the Arduino drivers, or try a difference USB cable.  Also try your "Arduino" on another computer.

Interesting. The USB chip is Amtel AT MEGA16U2. I've tried on a completely different system (macbook air which also was working before today) and it didn't make a difference.

Solved: It was the cable.

The 16U2 was used on the R2 - they upgraded to the 32U4 for the R3 IIRC.

+1 for guessing it was the cable, Makenko. I just want to comment that I found some USB cables (eg. to a USB light or fan) do not have data wires. That is, to save money, they only use two wires, which carry the 5V power and ground, and omit the A/B data wires. Naturally such cables do not work as data cables, and therefore plugging into a PC using one achieves nothing.

@NickGammon It wasn't a guess - just weighing up the balance of probability - probably skewed slightly in (dis)favour of Windows failing, but that's personal bias...

before today, the setup was functional - yes, but ... How come it worked yesterday? Does the OP mean: Before today, the setup was functional, I then changed USB cables and it stopped working. However I never expected the change in cable to be the problem. ?

@NickGammon If the OP is anything like me all the USB cables are in a tangled mess on the desk, and one is just grabbed at random for use at that specific moment.  Never the same cable twice.  Of course, if I find one of my cables has stopped working, I cut the ends off it and strip the wires out of it to re-use them for something else...

@NickGammon dunno, I guess the cable simply failed today. I didn't change it and pick up the wrong one.

@Sklivvz Cables fail. Especially cheap chinese ones. My parents have gone through 6 charge cables for their iPad this year. at 3 for 99p from china it's no problem, just annoying.


text:
Smart Servo Shield: How to upload code to AtMega8
I recently bought a Smart Servo Shield controller from DFrobot to use with my new AX-12A Dynamixel servos. The shield is attached to an Arduino Uno. The shield itself works fine, but it does not support all of the functions that I need. The shield has an AtMega8 on board, and they also give you the slave code that it runs to look over. If I were to modify said slave code, is there a way for me to upload to the shield's controller? If so, how would I go about doing that?
Smart Servo Shield
http://www.dfrobot.com/index.php?route=product/product&product_id=958#.VfXqzxFVhBc

Like the wiki says, remove the solder jumpers from the "UART SELECT" jumpers and connect to the "UART FOR Atmega8" connector in order to program it via serial. Don't forget to replace the solder jumpers after.
If you want to use ISP instead then make sure to remove the shield from the Arduino first since the shield connects all the ATmega8 ISP lines directly to the Arduino ISP lines.

source: Stack Exchange

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

sort: votes


text:
Ethernet to Cellular Modem Possible? | GSM + Ethernet + Arduino
Is it possible to combine an Arduino µC with a GSM shield and an ethernet shield such that a device connected via ethernet to the Arduino has internet access over the GSM network?
I have a system with an ethernet port to connect to the internet. It works fine if I plug it into my switch at home. However, I would like this system to have its own cellular internet connection.
This is what I have found so far:

I'm basically trying to replicate the following:
https://nimbelink.com/e2clink-ethernet2cellular/#parts
If the following reddit post:
https://www.reddit.com/r/arduino/comments/3azxs6/create_gsm_cellular_ethernet_modem_with_arduino/
is any indication, I would think the answer is "no" but I am hoping to confirm from the expertise available here.

I'd suggest using a TP-Link Portable 3G/3.75G Wireless N Router (TL-MR3020), together with a USB 3G dongle. Probably cheaper also.

You're right! This seems to be even a cheaper option than using a Raspberry Pi 2 + USB 3G dongle. Thanks.

No, it's not possible.
Chiefly because the normal Ethernet shield is not capable of routing.  The Arduino never talks to the ethernet - it talks to the chip on the shield and tells it how to handle the ethernet connection - everything else is then done by the ethernet chip and the results passed back to the Arduino.
Similarly with GSM - you make requests to it and it goes off and does the work.
To link the two together you would need raw access to the incoming ethernet packets, and you would then have to perform NAT (Network Address Translation) and maintain internal state tables for current streams and such, and pass reformatted packets on to a GSM modem that could accept raw data like that.
Way outside the scope of a lowly Arduino.
Maybe possible with one of the higher end Arduino-ish systems like the Edison, Galileo or Yun (just) since they run Linux and have a real Ethernet port and a proper USB port to communicate with a proper celular modem.

Thanks Majenko, that makes sense and explains it nicely. I will check out the systems you've mentioned.
Also, do you think a Raspberry Pi 2 would be able to do this instead, given it includes an on-board Ethernet & USB port(s)?

Yes, a Pi would do the job admirably - just plug in a typical USB data modem for HSDPA / 3G and configure it as the internet connection - then configure packet forwarding and NAT and all the other proper routing you'd need and you're good to go - just like doing it on any Linux computer. You can even do most of it graphically through the GUI. Just follow the myriad of tutorials out there for a generic Linux PC (Debian) - it's exactly the same.

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


text:
Client.connect galileo gen2 not working
I'm having a problem with the intel galileo gen2 ethernet. I am trying to get a webpage, but I can only connect to the ethernet, not the webpage.
I get this in the Serial monitor:

My code:
/*
  Web client

 This sketch connects to a website (http://www.google.com)
 using an Arduino Wiznet Ethernet shield.

 Circuit:
 * Ethernet shield attached to pins 10, 11, 12, 13

 created 18 Dec 2009
 by David A. Mellis
 modified 9 Apr 2012
 by Tom Igoe, based on work by Adrian McEwen

 */

#include <SPI.h>
#include <Ethernet.h>

// Enter a MAC address for your controller below.
// Newer Ethernet shields have a MAC address printed on a sticker on the shield
byte mac[] = { 0x98, 0x4f, 0xee, 0x01, 0x8d, 0xdf };
// if you don't want to use DNS (and reduce your sketch size)
// use the numeric IP instead of the name for the server:
IPAddress server(216, 58, 217, 206); // numeric IP for Google (no DNS)
//char server[] = "www.google.com";    // name address for Google (using DNS)

// Set the static IP address to use if the DHCP fails to assign
IPAddress ip(192, 168, 0, 177);
IPAddress dns(192, 168, 1, 122);
IPAddress gateway(192, 168, 1, 1);
IPAddress subnet(255, 255, 255, 0);

// Initialize the Ethernet client library
// with the IP address and port of the server
// that you want to connect to (port 80 is default for HTTP):
EthernetClient client;

void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    // wait for serial port to connect. Needed for Leonardo only
  }
  delay(5000);
  // start the Ethernet connection:

  Ethernet.begin(mac, ip, dns, gateway, subnet);
  Serial.println("connected to ethernet");
  // give the Ethernet shield a second to initialize:
  delay(1000);
  Serial.println("connecting...");

  // if you get a connection, report back via serial:
  int ch = client.connect(server, 80);
  if (ch) {
    Serial.println("connected");
    // Make a HTTP request:
    client.println("GET /search?q=arduino HTTP/1.1");
    client.println("Host: www.google.com");
    client.println("Connection: close");
    client.println();
  }
  else {
    // kf you didn't get a connection to the server:
    Serial.print("connection failed, error code ");
    Serial.println(ch);
  }
}

void loop()
{
  // if there are incoming bytes available
  // from the server, read them and print them:
  if (client.available()) {
    char c = client.read();
    Serial.print(c);
  }

  // if the server's disconnected, stop the client:
  if (!client.connected()) {
    Serial.println();
    Serial.println("disconnecting.");
    client.stop();

    // do nothing forevermore:
    while (true);
  }
}

Any help is greatly appreciated.

6 months after figuring out the answer, I found this question again. I solved this question by adding system("ifup eth0") which completely solved the problem.


text:
Problem with Arduino code
Please help me with this code it's shows some error [but I can't be bothered to tell you what].
#include <TimerOne.h>

/**

 Analog Clock

 Paul Cox Dec 2010

*/

#define    PI       3.141592653589793e-06;

byte rows[8] = {9, 14, 8, 12, 1, 7, 2, 5};

byte cols[8] = {13, 3, 4, 10, 6, 11, 15, 16};

byte pins[16] = {5, 4, 3, 2, 14, 15, 16, 17, 13, 12, 11, 10, 9, 8, 7, 6};

byte screen[8] = {0, 0, 0, 0, 0, 0, 0, 0};

volatile byte screenRow = 0;

volatile byte screenCol = 0;

int iHour = 0;

int iMin = 0;

int iSec = 0;

void setup()

{

  Timer1.initialize(100);

  for (int i = 2; i <= 17; i++)

  {

     pinMode(i, OUTPUT);

  }

  Timer1.attachInterrupt(doubleBuffer);

  Serial.begin(9600);

  resetAnim();

}

void doubleBuffer()

{

  digitalWrite(translatePin(rows[screenRow]), LOW);

  digitalWrite(translatePin(cols[screenCol]), HIGH);

  screenCol++;

  if (screenCol >= 8)

  {

     screenCol = 0;

     screenRow++;

     if (screenRow >= 8)

     {

       screenRow = 0;

     }

   }

   if((screen[screenRow] >> screenCol) & B1 == B1)

   {

     digitalWrite(translatePin(rows[screenRow]), HIGH);

     digitalWrite(translatePin(cols[screenCol]), LOW);

   }

   else

   {

     digitalWrite(translatePin(rows[screenRow]), LOW);

     digitalWrite(translatePin(cols[screenCol]), HIGH);

   }

}

byte translatePin(byte original)

{

  return pins[original - 1];

}

void allOFF()

{

  for (int i = 0; i < 8; i++)

  {

     screen[i] = 0;

  }

}

void on(byte row, byte column)

{

  screen[column-1] |= (B1 << (row - 1));

}

void off(byte row, byte column)

{

  screen[column-1] &= ~(B1 << (row - 1));

}

void resetAnim()

{

  for (int i = 0; i < 8; i++)

  {

     screen[i] = B11111111;

     delay(25);

  }

  for (int i = 0; i < 8; i++)

  {

     screen[i] = B00000000;

     delay(25);

  }

}

void loop()

{

  drawClock();

  iSec++;

  if (iSec == 60)

  {

    iSec = 1;

    iMin++;

    if (iMin == 60)

    {

       iMin = 0;

       iHour++;

       if (iHour == 12)

       {

          iHour = 0;

       }

    }

  }

  delay(10);

}

void drawClock()

{

  allOFF();

  setHand(iHour,12,3);

  setHand(iMin,60,4);

  setHand(iSec,60,5);

}

// work out the pixel for a hand - val is out of a possible max val

// radius is distance from the centre

void setHand(int iVal, int iMax, int iRadius)

{

  double  dAngle = (iVal * 2 * PI) / iMax;

  double  dPosX = 4.5 + (iRadius * cos(dAngle));

  double  dPosY = 4.5 + (iRadius * sin(dAngle));

  drawLine(5,5,constrain(round(dPosX),1,8),constrain(round(dPosY),1,8));

}

void drawLine(int x0, int y0, int x1, int y1)

{

  int      iTemp;

  boolean  bSteep = abs(y1 - y0) > abs(x1 - x0);

  if (bSteep)

  {

     iTemp = x0; x0 = y0; y0 = iTemp;    // swap x0,y0

     iTemp = x1; x1 = y1; y1 = iTemp;    // swap x1,y1

  }

  if (x0 > x1)

  {

     iTemp = x0; x0 = x1; x1 = iTemp;    // swap x0,x1

     iTemp = y1; y1 = y0; y0 = iTemp;    // swap y0,y1

  }

  int deltax = x1 - x0;

  int deltay = abs(y1 - y0);

  int error = deltax / 2;

  int ystep = ((y0 < y1) ? 1 : -1);

  int y = y0;

  int x = x0;

  while(x <= x1)

  {
    if (bSteep)
    {
       on(y,x);
    }
    else
    {
       on(x,y);
    }
    error = error - deltay;
    if (error < 0)
    {
       y = y + ystep;
       error = error + deltax;
    }
    x++;
  }
}

What error does it show?  And please format the code as a code block - highlight the code and press {} at the top of the editor.

I#ll do it for you this once, but next time format your question properly.  Also ask your question in the question area, not in the title!

#define    PI       3.141592653589793e-06; - apart from the semicolon problem, π is not 0.000003141592654.

"it's shows some error [but I can't be bothered to tell you what]." I'm amazed anybody has bothered to tell you what the problem was.

A selfish can tell the comment like you my friend. all minds are not same. I SOLVED MY problem with other  friend  named Majenko. some people have good heart not like you .  any way thank you very much.

@shinas The whole point of the error report in Arduino IDE (any all other IDEs, for that matter) is to tell you what the error is. You're lucky that the mistake in your code is almost the very first line and therefore very easy to spot. Nobody on the internet is telepathic anymore.

It's amazing the difference one character can make:

You must NEVER terminate a #define with a ; unless you absolutely know that you need one when it is expanded.

You have a macro defined:
#define    PI       3.141592653589793e-06;

That macro is then used here:
double  dAngle = (iVal * 2 * PI) / iMax;

Expand the macro PI and you get:
double  dAngle = (iVal * 2 * 3.141592653589793e-06;) / iMax;

Which obviously is a syntax error - you have a rogue ; in there where you really don't want one.
Oh, and one other thing - you shouldn't define PI - the Arudino core already defines it for you to a greater accuracy than you are:
arduino/Arduino.h:#define PI 3.1415926535897932384626433832795

... though you seem to be working in microPi's whatever those are...

Maybe he's using an Arduino Micro?

@NickGammon Or he moves in MicroCircles....


text:
Why are there 3 crystals on the Mega2560 schematic?
I am a software engineer who is new(er) to electronics, I only started a couple of months ago. I've built a bunch of custom circuits, then some arduino nodes that are around my apartment that communicate with a C# server. So I've at least got the breadboarding part down.
So now I am working on a controller board that connects to my home automation system and determines the color on the LED light strips I installed into my bookshelf. So I want to transfer from working with pre-built Arduinos to building my own full node, there are some things I think I'm missing.
I've noticed that there are duplicate parts on the schematic for the Arduino Mega2560 schematic (such as there being 2 voltage regulators - one is replacement if the other is not available). I couldn't find any such description however for why there are 3 crystals located on the board. I see 3 different circuits for crystals (all of which are 16MHz).
Specifically, I am referencing the following

Maybe different options. The top one may be a ceramic resonator rather than a crystal. What's actually fitted on the board? The other one with XT1 and XT2 may be for the FTDI serial chip.

Where did you get that schematic? That is not from the R3 schematic on arduino.cc.

link

@jippie That's a good point, I will trace back XT1 to see if it comes from the FTDI. This brings up an additional question, why are the FTDI chip and the ATMega on different clocks?

@jippie there is no FTDI chip on the R3. It is an ATMega8U2.

A second crystal may be cheaper than sharing the clock between the two.

Also, you can't ideally share a crystal between two ICs, the two oscillation circuits would likely affect each other. You could have one connect to the crystal and then feed a buffered clock to the other, but that would cost an I/O pin.

A shame this was migrated; it is actually a very good general EE question.

One of the crystals is for the ATMega8U2 chip which is being used for USB-Serial conversion.
The other two crystals are both for the ATMega2560. Why two? Basically they only populate one of the two, but they have two different footprints. One is for a surface mount resonator, the other for a through-hole crystal.
Having two footprints gives the option during assembly to go for the cheapest package at the time. It also means that the hobbyist can replaces the low accuracy resonator with a high accuracy crystal if their project requires.

As a side note, if you look at Y1, you will notice it is not the symbol for a crystal, it is of a resonator.

Awesome! I couldn't tell why the design was different. I am new to the hardware side of things, could you point me to where I could find some information on how resonators and crystals are different?

@clamport See thisEE.SE question and this PDF. Or just google "crystal vs ceramic resonator".

@NickAlexeev it does - look in the top right corner.

@TomCarpenter  Also of note: the current version of the Eagle files for Arduino Mega2560 doesn't seem to have the spare footprints Q1 and Q2.


text:
How do I start a function with serial input?
I want to create a LED Sunrise/Sundown alarm clock. Therefore, I will use a Raspberry Pi that is sending commands over serial to a Teensy 3.1. Like:

"30 Minute Sunrise starting with Color(255,140,0)"
"20 Minute Sundown with Color(255,140,0)"
"start something else with these 3 parameter.

But I don't even get the basic serial part working. E.g. I tried this:
void setup() {
  Serial.begin(9600);
  strip.begin();
  strip.show(); // Initialize all pixels to 'off'
}

void loop() {
  if (Serial.available() > 0) {
    if (Serial.read() == 'A'){
      int inte1 = Serial.parseInt();
      int inte2 = Serial.parseInt();
      int inte3 = Serial.parseInt();
      int inte4 = Serial.parseInt();
      int inte5 = Serial.parseInt();
      if (Serial.read() == '\n') {
        Serial.print(inte1);
        Serial.print(inte2);
        Serial.print(inte3);
        Serial.print(inte4);
        Serial.println(inte5);
      }
    }
  }
}

I planned to do a case switch afterwards. Inte1 should define sunrise/sundown, Inte2 the minutes, 'Inte3-5' the rgb color.
However, when I enter "A 1 100 100 100" it is not printing anything at all.
What is the best way do get this working?
Thanks in advance!

Suggested reading: http://hacking.majenko.co.uk/reading-serial-on-the-arduino

Thank you, that was a nice read. The examples compiles fine and I get what this is about, but still not working. Does not print a single line on the serial monitor!

Baud in Teensy and serial monitor is the same!

Have you managed to get even simple "echo what you send" serial communication working?

Yes. Right now: 'char exstr = Serial.read(); Serial.print(exstr)' is working. I don't know why the example does not!

Probably because you're not waiting for the \n and expecting it to already be in the serial buffer when it hasn't actually arrived yet. Don't expect it to be there immediately you have parsed the last int.

I think Majenko is right. Suggested alternative method: How to process incoming serial data without blocking

Yes that \n was missing. Without it does work.

Okay, as Majenko and Nick Gammon have suggested. The \n had not arrived in the serial buffer. That way the if clause was not fulfilled and nothing was printed. This code has worked for me now:
if (Serial.available() > 0) {
 if (Serial.read() == 'A'){
  char inte1 = Serial.read();
  int inte2 = Serial.parseInt();
  int inte3 = Serial.parseInt();
  int inte4 = Serial.parseInt();
  int inte5 = Serial.parseInt();
  Serial.print(inte1);
  Serial.print(inte2);
  Serial.print(inte3);
  Serial.print(inte4);
  Serial.println(inte5);
 }
}

Although i read quite a bit now, serial input is still a mystery to me.


text:
Where to get the potentiometer that comes with Arduino kit
Does anyone know where I can get the potentiometer that comes with the Arduino kit? You can see them here.
They are sold out on their website.

There is a radio shack in your town. Kailus-Kona. You can pick up any pot you like there

It's just any old trimmer pot. It's nothing special. Why do you feel you need that specific one? Any pot (of the right value) will do.  What value is it? (That datasheet is a generic one for all values).
Visit your favourite electronics retailer (IRL or on line) and pick a pot that is a suitable value and jiffles your tipples.

10k. I just want these because I've used them and know they work for what I want. Try to find anything like these on Amazon. None of them have knobs.

Amazon is not an electronics retailer.  Any linear tracked 10K pot "will work" for you. Everything else is just looks.

Ok please find me a link to any site that sells trimmer pots with knobs.

https://www.google.com/search?q=trimmer+pot+knob&ie=utf-8&oe=utf-8#q=trimmer+pot+knob&tbm=shop

Here's one, https://www.sparkfun.com/products/9288 but it's not a trimmer pot

That google search didn't help. I tried that.

Please, tell me why you feel you need a trim pot with a knob? Why not a trim pot without a knob, or a normal pot? What is so special about a trim pot with a knob?

Because it's perfect for a servo that only rotates 180 degrees. And I need the knob to turn it. lol

What on god's earth has the style of pot got to do with the fact that a servo rotates 180°?

I thought a trimmer pot turns only 180 degrees. The Arudino one I have does. I ordered some other ones and they spin in circles.

They spin in circles because you force them past the end of the track. Keep doing that and you will probably break them.  If you want to have a pot only work for 180° then program it to only work for 180° - don't rely on finding a very esoteric pot that can't be found. Settle for a cheap generic one and do the rest in software.

Software isn't going to stop the knob from spinning around. Like I said the Arduino ones found above do exactly what I need. They aren't like volume knobs, they rotate only a certain amount.

Normal pots only rotate a certain amount. Cheap trim pots can very easily be forced around too far, often without knowing it.  The actual sensitive area will only be somewhere between 180 and 270°.


text:
Looking for circuit diagram for evaluation of a pulsed signal
How can I evaluate a pulsed signal in Arduino? The signal comes from an car alarm system and is called (-) output 200 mA. Arduino and the car have the same GND. Can I attach the output through a resistor to PB0 (D8) or PD5 (D5)?
Alarm system is called Ampire. Probably the same as Viper. I just wanted to read these pulses, but I do not know exactly how I connect this output correctly with Arduino.
This is the description for this Output:

HN1/9 BROWN/WHITE – 200mA (-) Horn honk output: This wire supplies a 200mA (-) output that can be used to honk the vehicle’s horn. It provides a pulsed output when the security system is armed/disarmed and in trigger sequence or in panic mode. In most vehicles with (-) horn circuits this wire can control the vehicle’s horn without adding a relay. If the vehicle has a (+) horn circuit, an optional relay must be used to interface with the vehicle’s horn circuit.

What brand alarm system? When you say (-) output does that mean it is negative? This is a hard question to answer with so little information.

@NickGammon It sounds to me like it might be an open drain output with a current limit of 200mA but that's just wild surmising.

Alarm system is called Ampire. Probably the same as Viper. And yes, the output is negative transistor output with limited current. The system sends certain impulses when the alarm is triggered (panic alarm, full alarm). I just wanted to read these pulses, but I do not know exactly how I connect this output correctly with Arduino.

This is the description for this Output: HN1/9 BROWN/WHITE – 200mA (-) Horn honk output: This wire supplies a 200mA (-) output that can be used to honk the vehicle’s horn. It provides a pulsed output when the security system is armed/disarmed and in trigger sequence or in panic mode. In most vehicles with (-) horn circuits this wire can control the vehicle’s horn without adding a relay. If the vehicle has a (+) horn circuit, an optional relay must be used to interface with the vehicle’s horn circuit.

Can you edit this extra information into the question please? It will look better, as you can put in line breaks, and then the question makes more sense.

I found a user manual at AMPIRE Car Alarm System for High-Speed CAN-Bus.

N1/9 BROWN/WHITE – 200mA (-) Horn honk output:
This wire supplies a 200mA (-) output that can be
  used to honk the vehicle’s horn. It provides a pulsed output when the security system is armed/disarmed
  and in trigger sequence or in panic mode. In most vehicles with (-) horn circuits this wire can control the
  vehicle’s horn without adding a relay. If the vehicle has a (+) horn circuit, an optional relay must be used
  to interface with the vehicle’s horn circuit.
IMPORTANT!
   Never use this wire to drive anything but a relay or a low-current input! This transistorized output can only supply (-) 200mA and connecting directly to a solenoid, motor or other high current device will cause the module to fall

Judging by that this output will sink up to 200 mA. You could conceivably set an Arduino pin to INPUT_PULLUP and let this output drive it low to indicate it is active.
Personally I think I would use an optocoupler, in case there were unexpected voltages on that pin. You would need a series resistor to limit current through the LED in the optocoupler, say 1 k would be about right if you were connecting it to the 12V car system.
Vf = 1.2V (say)
Voltage over resistor = 12 - 1.2 = 10.8 volts
Current through LED = 10 mA
Limiting resistor = 10.8 / 0.01 = 1080 ohms

Now the output of the optocoupler can sink your Arduino pin, which you have configured as input pullup.
Write a test sketch to see what you are getting through it, but a multimeter should probably tell you, if it just flashes it slowly.

Suggested schematic:

Many thanks, Nick! I'll try to implement your suggestions in a circuit diagram.

See amended post with schematic.


text:
Making servo spin and able to detect angle
After researching other posts I can see how to make a servo spin continually and remove the ability to set to a specific angle.
What I'm trying to do is make a small project that has a spinning 'game wheel', each segment of the wheel has a prize on it (think almost wheel of fortune). The catch is when someone has landed on a prize once it cannot be landed on again so I want to manipulate the spin slightly so it doesn't stop on the same prize. Do do this I need to be able to get the spin AND know where the needle is pointing.
Is there a component that will allow both a full rotation AND the ability to control the location of the needle at the same time? I suspect servos can do one, or the either but not both.

I think you should look into stepper motors

Look into 'optical encoders'

The way I'd do it is the following:

use an optical encoder with an endstop, they come @ 1€ on ebay, bought 4 today :-) - this will tell you the angular speed and incremental position
use a photo transistor to detect a specific point on the wheel (make a small hole or paint a spot in a different colour) - this will give you
the absolute position of the wheel, to calibrate the previous step.

With this solution you do not even need a step motor, a DC motor will do it and probably has better characteristics, for the same cost.
So you could explore the DC option if it turns out that the stepper is not good enough.

As for Me the Best Way to To Use a Position Servo with the Feedback in it ( it comes with 6 wire ) then You put all Your Positions For the prizes in An Array and if Anytime You Land on An Index then You Should but it in an Array that Holds all the prizes angle visited Which you will use as a check Before Turning the Servo

Darkclaude X, please edit your question to get rid of all those capitalization errors.


text:
Can't program bareduino. "avrdude: stk500_recv(): programmer is not responding"
I've built a bareduino. The blink sketch that it came preprogrammed with worked. I was also able to program the ATmega328 by putting it into a arduino uno.
What I can't do is upload a sketch directly. I've tried both of the methods described here: https://www.virtuabotix.com/bareduino328-programming-guide/
I've used FTDI before and I know that my drivers work. I've tried suggestions from many forums and after 3 hours I'm running out of options.
The issue seems to be the reset pin. But the fixes here have not worked. I must admit I'm confused about how to un-ground the reset pin. I tried unplugging the power. When I tried to upload with FTDI I had a capacitor... so shouldn't that fix this error?
Verbose Error Code:
Sketch uses 7,920 bytes (24%) of program storage space. Maximum is 32,256 bytes.
Global variables use 383 bytes (18%) of dynamic memory, leaving 1,665 bytes for local variables. Maximum is 2,048 bytes.
/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avrdude -C/Applications/Arduino.app/Contents/Java/hardware/tools/avr/etc/avrdude.conf -v -patmega328p -carduino -P/dev/cu.usbmodem1d11 -b115200 -D -Uflash:w:/var/folders/r9/t7hwvgjx1kz18v8j60_kp_vh0000gn/T/build7068227750495702499.tmp/webclient.cpp.hex:i

avrdude: Version 6.0.1, compiled on Apr 14 2015 at 16:30:25
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "/Applications/Arduino.app/Contents/Java/hardware/tools/avr/etc/avrdude.conf"
         User configuration file is "/Users/futurebird/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : /dev/cu.usbmodem1d11
         Using Programmer              : arduino
         Overriding Baud Rate          : 115200
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x00

avrdude done.  Thank you.

Problem uploading to board.  See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.

What are your fuses set to? Where is this capacitor? It should be between RTS on the FTDI cable and Reset, and Reset should have a 10k pull-up resistor to +5V. Which bootloader is on the chip?

It's like this: https://virtuabotix-virtuabotixllc.netdna-ssl.com/core/wp-content/uploads/2012/03/arduinoserialpinout_small.jpg
It has a uno bootloader

What are the fuses set to? If you don't know you can find out with my Signature detector sketch.

Also try manually resetting the bareduino with a grounded wire shortly before or after you begin the upload. If that works, then the fault is with the the auto-reset circuit.


text:
Potentiometer won't work
I'm trying to get the potentiometer seen at the top left of the photo to work, essentially as a dimmer. I've managed to upload the Arduino sketch, but it isn't working. Any help would be greatly appreciated!
NB: I have little-to-no electronics experience so my understanding of jargon is limited.
Thanks!
/*
 SENSOR_LIGHTS: Potentiometer >> LED (Single Channel Script)

 This example dims light levels using an LED on pin 11
 and a potentiometer on A0.

 Created by Ryan Achten | SOMA | somavisions.com

 This example code is in the public domain.
 */

int potentLevel;
int ledLevel;

//*************************CHECK*****************************

int led = 11;           // the pin that the LED is attached to
int inputPin = A0;      // the pin that the potentiometer is attached to

//*************************CALIBRATE*************************

const int numReadings = 1;  //change this to alter the number of values to be averaged
int potentMin = 280;
int potentMax = 700;        //maximum output from potentiometer
int loopDelay = 100;       //delay time between loops. Too low may cause overclocking
//                            while too high may cause delayed sensor response

//***********************************************************

int potentAve = 0;
int readings[numReadings];
int index = 0;
int total = 0;

// the setup routine runs once when you press reset:
void setup()  {

  //*************************POTENT >> LED SETUP CODE*************************

  Serial.begin(9600);

  pinMode(led, OUTPUT);

  //***************************SMOOTH SETUP CODE*****************************
  // initialise all the readings to 0:
  for (int thisReading = 0; thisReading < numReadings; thisReading++)
    readings[thisReading] = 0;

}

//****************************SMOOTH LOOP CODE****************************

void loop()  {

  total= total - readings[index];
  readings[index] = analogRead(inputPin);
  total= total + readings[index];
  index = index + 1;

  if (index >= numReadings)
    index = 0;

  potentAve = total / numReadings;
  Serial.print("Average Potentiometer Readings: ");
  Serial.println(potentAve);

  //*************************POTENT >> LED LOOP CODE*************************

  ledLevel = map(potentAve, potentMin, potentMax, 0, 255);
  Serial.print("LED Level: ");
  Serial.println(ledLevel, DEC);
  analogWrite(led, ledLevel);

  Serial.println();
  delay(loopDelay);

}

According to your schematic, it seems that both the red and the blue wire of the potentiometer are connected to GND? If so, this will never work. What does your Serial output tell for "Average Potentiometer Readings"?

Yes, this was one problem! I'd put it in GND instead of 5V by accident. Thanks for that!

Assuming the brown board in your drawing is stripboard, I have to as the question:
What is this?

If those five wires in that column are all ground, that link is basically short circuiting your MOSFET via the green wire next to it, thus rendering your whole circuit pointless.  The LEDs will just be on full brightness permanently since the current just flows from the input power, through the LED strip, through the red/white wire, through that little white link wire, then through the green/white and/or the brown/white wires to ground.

It was a wire I was using to replace a resistor, because some classmates found that getting rid of the resistor meant that the LED strip would go all the way off, which they don't otherwise. I've given up on that and put a resistor in, and now it works. Thanks for your help!


text:
Problem in SIM900 GPRS connection
I make simple code to read web page by ITEAD Gboard. Here is my code:
  Serial.write("\nStarting..........\n");
  mySerial.print("AT+CSQ");
  delay(1000);

  while(mySerial.available()!=0)
    Serial.write(mySerial.read());

  Serial.write("\n-----1-----\n");

  mySerial.println("AT+CGATT=1");
  delay(1000);

  while(mySerial.available()!=0)
    Serial.write(mySerial.read());

  Serial.write("\n-----2-----\n");

  mySerial.println("AT+CGATT?");
  delay(1000);

  while(mySerial.available()!=0)
    Serial.write(mySerial.read());

  Serial.write("\n-----3-----\n");

  mySerial.print("AT+SAPBR=3,1,\"CONTYPE\",\"GPRS\"");
  delay(1000);

  while(mySerial.available()!=0)
    Serial.write(mySerial.read());

  Serial.write("\n-----4-----\n");

  mySerial.print("AT+SAPBR=3,1,\"APN\",\"internet\"");
  delay(2000);

  while(mySerial.available()!=0)
    Serial.write(mySerial.read());

  Serial.write("\n-----5-----\n");

  mySerial.print("AT+SAPBR=1,1");
  delay(1000);

  while(mySerial.available()!=0)
    Serial.write(mySerial.read());

  Serial.write("\n-----6-----\n");

  mySerial.print("AT+HTTPINIT");
  delay(1000);

  while(mySerial.available()!=0)
    Serial.write(mySerial.read());

  Serial.write("\n-----7-----\n");

  mySerial.print("AT+HTTPPARA=\"URL\",\"xx.xx.xx.xx/my/web/site\"");
  delay(1000);

  while(mySerial.available()!=0)
    Serial.write(mySerial.read());

  Serial.write("\n-----8-----\n");

  mySerial.print("AT+HTTPDATA=100,1000");
  delay(10000);

  while(mySerial.available()!=0)
    Serial.write(mySerial.read());

  Serial.write("\n-----9-----\n");

  mySerial.println("AT+HTTPREAD");
  delay(1000);

  while(mySerial.available()!=0)
    Serial.write(mySerial.read());

  Serial.write("\nend.\n");

Which i get the following output:
Starting..........
AT+CSQ
-----1-----
AT+CGATT=1

ERROR

-----2-----
AT+CGATT?

+CGATT: 1

OK

-----3-----
AT+SAPBR=3,1,"CONTYPE","GPRS"
-----4-----
AT+SAPBR=3,1,"APN","internet"
-----5-----
AT+SAPBR=1,1
-----6-----
AT+HTTPINIT
-----7-----
AT+HTTPPARA="URL","xx.xx.xx.xx/my/web/site"
-----8-----
AT+HTTPDATA=100,1000
-----9-----
AT+HTTPREAD

ERROR

end.

AT+HTTPREAD return error. What wrong with me?
Note
xx.xx.xx.xx/my/web/site is my web page. The error is still there for all web page.

I think the problem started from step 3 which i dont see the OK output

The problem (I believe) is that half way through your program you switched from using println() to using print(), thus the commands from that point on aren't being executed until right at the end where you switch back to println(), so the whole of the text you send from point 3 onwards is being run as one single command - which of course is in the wrong format:

AT+SAPBR=3,1,"CONTYPE","GPRS"AT+SAPBR=3,1,"APN","internet"AT+SAPBR=1,1AT+HTTPINITAT+HTTPPARA="URL","xx.xx.xx.xx/my/web/site"AT+HTTPDATA=100,1000AT+HTTPREAD


text:
Arduino code (on board) runs really slow
Stumbled upon this weirdest behavior, from time to time, my Arduino (UNO) runs gode really slow.
Searching this issue didn't clarify anything, most people have problems with IDE itself. My issue is related to actual board.
Heres a sample of my flow:

I compile & upload my sketch, all good
first initiation of program on the board seems to be "fast"
when I start to "animate" the neopixels it goes 3-4 times slower than it should
I'll touch the board, and animation goes fast again.

Here's a clip of that, at the end you'll see the "slowness"

Test environment:

Live environment:

The Touching part, is almost like if I "add" static electricity from my finger to the board, it wakes up and behaves normally.
For you who are curious about (non related) what animation I'm doing on neopixels, I'm turning on 15 pixels from 0 to 54. Like a "slide effect".
(I'm not using delay, only a delay(30) in the loop, rest of the delays are based on millis())
Is there any general info / explanation that would explain this behavior, like in electronics, arduino boards specifically ?
EDIT: I should also add, when printing logs into serial monitor, that slowness also affects the  outputs... they appear as "slow" as the pixels flow. When all works normally, I see pixels change and logs 50 times per second (roughly), but in this slow motion, I see pixels change and logs around 20 times per second.  Taking out the Serial entirely from the code doesn't seem to have effect.
Code:
#include <Adafruit_NeoPixel.h>
#include <avr/power.h>
#define LEFT_BLINK_IN 2
#define RIGHT_BLINK_IN 3
#define PIN           6
#define NUMPIXELS     54
Adafruit_NeoPixel     leftLight = Adafruit_NeoPixel(NUMPIXELS, 6, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel     rightLight = Adafruit_NeoPixel(NUMPIXELS, 10, NEO_GRB + NEO_KHZ800);
int leftBlinkCount   = 0;
int rightBlinkCount  = 0;
int PIXELTOSHOW      = 20;
bool OEM_RIGHT_ON    = false;
bool OEM_LEFT_ON     = false;
int R_PIXEL          = -1;
int L_PIXEL          = -1;
int G_PIXEL          = -1;
int D_PIXEL          = -1;
char LAST_COMMAND;
bool DRL_ON         = false;
int DRL_STARTPIXEL  = 35;
uint32_t COLOR_YEL = rightLight.Color(240, 120, 0);
uint32_t COLOR_RED = rightLight.Color(255, 0, 0);
uint32_t COLOR_BLU = rightLight.Color(0, 0, 255);
uint32_t COLOR_NON = rightLight.Color(0, 0, 0);
uint32_t COLOR_WHI = rightLight.Color(255, 255, 255);

unsigned long rightPrevMillis = 0;
unsigned long leftPrevMillis = 0;
unsigned long generalPrevMillis = 0;
const long PIXEL_SWITCH_INTERVAL = 5;

int DRL_RESETER_LEFT = 0;
int DRL_RESETER_RIGHT = 0;

void welcome()
{
  int totalPixels = (NUMPIXELS + PIXELTOSHOW);
  while (G_PIXEL < totalPixels) {
    unsigned long leftCurrentMillis = millis();
    if (leftCurrentMillis - leftPrevMillis >= 12) {
      leftLight.setPixelColor(totalPixels - G_PIXEL, COLOR_WHI);
      rightLight.setPixelColor(totalPixels - G_PIXEL, COLOR_WHI);
      if (G_PIXEL >= 10) {
        leftLight.setPixelColor(totalPixels - G_PIXEL + PIXELTOSHOW , COLOR_NON);
        rightLight.setPixelColor(totalPixels - G_PIXEL + PIXELTOSHOW , COLOR_NON);
      }
      leftLight.show();
      rightLight.show();
      G_PIXEL++;
      leftPrevMillis = leftCurrentMillis;
    }
  }
  G_PIXEL = 0;
  while (G_PIXEL < totalPixels) {
    unsigned long leftCurrentMillis = millis();
    if (leftCurrentMillis - leftPrevMillis >= 12) {
      leftLight.setPixelColor(G_PIXEL, COLOR_WHI);
      rightLight.setPixelColor(G_PIXEL, COLOR_WHI);
      if (G_PIXEL >= 10) {
        leftLight.setPixelColor(G_PIXEL - PIXELTOSHOW, COLOR_NON);
        rightLight.setPixelColor(G_PIXEL - PIXELTOSHOW, COLOR_NON);
      }
      leftLight.show();
      rightLight.show();
      G_PIXEL++;
      leftPrevMillis = leftCurrentMillis;
    }
  }
}

void blinkRight()
{

  //slidePixels(rightBlinkCount, R_PIXEL, rightLight);
  if (rightBlinkCount > 0 && R_PIXEL > -1)
  {
      //Serial.println("RIGHT "+String(rightBlinkCount));
    LAST_COMMAND = ' ';
    unsigned long rightCurrentMillis = millis();
    if (rightCurrentMillis - rightPrevMillis >= PIXEL_SWITCH_INTERVAL) {
      rightLight.setPixelColor(R_PIXEL, COLOR_YEL);
      if (R_PIXEL >= PIXELTOSHOW)
      {
        rightLight.setPixelColor(R_PIXEL - PIXELTOSHOW, COLOR_NON);
        if (G_PIXEL > -1 && DRL_ON == false) {
          leftLight.setPixelColor(R_PIXEL - PIXELTOSHOW, COLOR_NON);
        }
      }
      leftLight.show();
      rightLight.show();
      R_PIXEL++;
      rightPrevMillis = rightCurrentMillis;
    }
    if ( R_PIXEL >= (NUMPIXELS + PIXELTOSHOW)) {
      rightBlinkCount--;
      if ( rightBlinkCount > -1 ) {
        R_PIXEL = DRL_RESETER_RIGHT = 0;
      } else {
        L_PIXEL = G_PIXEL = -1;
      }
      if(DRL_ON){
        D_PIXEL=DRL_STARTPIXEL;
      }
    }
  }

  }

  void blinkLeft() {
  //  slidePixels(leftBlinkCount, L_PIXEL, leftLight);

    if (leftBlinkCount > 0 && L_PIXEL > -1)
  {
          //Serial.println("left  "+String(rightBlinkCount));
    LAST_COMMAND = ' ';
    unsigned long leftCurrentMillis = millis();
    if (leftCurrentMillis - leftPrevMillis >= PIXEL_SWITCH_INTERVAL) {
      leftLight.setPixelColor(L_PIXEL, COLOR_YEL);
      if (L_PIXEL >= PIXELTOSHOW)
      {
        Serial.print(" "+String(L_PIXEL));
        leftLight.setPixelColor(L_PIXEL - PIXELTOSHOW, COLOR_NON);
        if (G_PIXEL > -1 && DRL_ON == false) {
          rightLight.setPixelColor(L_PIXEL - PIXELTOSHOW, COLOR_NON);

        }
      }
      rightLight.show();
      leftLight.show();
      L_PIXEL++;
      leftPrevMillis = leftCurrentMillis;
    }
    if ( L_PIXEL >= (NUMPIXELS + PIXELTOSHOW) ) {
      leftBlinkCount--;
      Serial.println("Count "+leftBlinkCount);
      if ( leftBlinkCount > -1 ) {
        L_PIXEL = DRL_RESETER_LEFT = 0;
      } else {
        L_PIXEL = G_PIXEL = -1;
      }
      if(DRL_ON){
        D_PIXEL=DRL_STARTPIXEL;
      }
    }
  }

}

/*void slidePixels(int &blinkCount, int &blinkPixel, Adafruit_NeoPixel &sideLight){
  if (blinkCount > 0 && blinkPixel > -1)
  {
    LAST_COMMAND = ' ';
    unsigned long leftCurrentMillis = millis();
    if (leftCurrentMillis - leftPrevMillis >= PIXEL_SWITCH_INTERVAL) {
      sideLight.setPixelColor(blinkPixel, COLOR_YEL);
      if (blinkPixel >= PIXELTOSHOW)
      {
        if(G_PIXEL>-1){
          rightLight.setPixelColor(blinkPixel - PIXELTOSHOW, COLOR_NON);
          leftLight.setPixelColor(blinkPixel - PIXELTOSHOW, COLOR_NON);
        }
      }
      rightLight.show();
      leftLight.show();
      blinkPixel++;
      leftPrevMillis = leftCurrentMillis;
    }
    if ( blinkPixel >= (NUMPIXELS + PIXELTOSHOW) ) {
      blinkCount--;
      if ( blinkCount > -1 ) {
        blinkPixel = 0;
      } else {
        blinkPixel = -1;
        if(DRL_ON){
          G_PIXEL = -1;
        }
      }
    }
  }
}*/

int switchRB = 0; // 0 = red, 1 = blue
void slideBlueRed() {
  unsigned long currentMillis = millis();
  if (currentMillis - generalPrevMillis >= 100) {
    if (switchRB == 0) {
      leftLight.setPixelColor(G_PIXEL, COLOR_RED);
      rightLight.setPixelColor(G_PIXEL, COLOR_RED);
    } else {
      leftLight.setPixelColor(G_PIXEL, COLOR_BLU);
      rightLight.setPixelColor(G_PIXEL, COLOR_BLU);
    }
    if (G_PIXEL >= 10) {
      leftLight.setPixelColor(G_PIXEL - PIXELTOSHOW, COLOR_NON);
      rightLight.setPixelColor(G_PIXEL - PIXELTOSHOW, COLOR_NON);
    }
    leftLight.show();
    rightLight.show();
    G_PIXEL++;
    generalPrevMillis = currentMillis;
  }
}

void drlLight(){

  unsigned long currentMillis = millis();
  if (D_PIXEL < NUMPIXELS) {
    leftLight.setPixelColor(NUMPIXELS-DRL_RESETER_LEFT, DRL_ON == true ? COLOR_WHI : COLOR_NON);
    rightLight.setPixelColor(NUMPIXELS-DRL_RESETER_RIGHT, DRL_ON == true ? COLOR_WHI : COLOR_NON);
    rightLight.setBrightness(128);
    leftLight.setBrightness(128);
    rightLight.show();
    leftLight.show();
    D_PIXEL++;
   //x //Serial.println(String(DRL_RESETER_LEFT) + " "+ String(NUMPIXELS - DRL_STARTPIXEL));
    if(DRL_RESETER_LEFT+1 < (NUMPIXELS - DRL_STARTPIXEL)){
      DRL_RESETER_LEFT++;
    }
    if(DRL_RESETER_RIGHT+1 < (NUMPIXELS - DRL_STARTPIXEL)){
      DRL_RESETER_RIGHT++;
    }
    generalPrevMillis = currentMillis;
  }

}

void setup() {
  Serial.begin(115200);
  leftLight.begin();
  rightLight.begin();
  pinMode(LEFT_BLINK_IN, INPUT);
  pinMode(RIGHT_BLINK_IN, INPUT);
  delay(50);
  welcome();
}

void loop() {

  if (digitalRead(LEFT_BLINK_IN) == HIGH) {
    if ( OEM_LEFT_ON == false ) {
      OEM_LEFT_ON = true;
      leftBlinkCount++;
      //Serial.println("LEFT "+String(leftBlinkCount));
      if (leftBlinkCount == 1) {
        L_PIXEL = 0;
      }
    }
  } else {
    OEM_LEFT_ON = false;
  }

  if (digitalRead(RIGHT_BLINK_IN) == HIGH) {
    if ( OEM_RIGHT_ON == false ) {
      OEM_RIGHT_ON = true;
      rightBlinkCount++;

      if (rightBlinkCount == 1) {
        R_PIXEL = 0;
      }
    }
  } else {
    OEM_RIGHT_ON = false;
  }

  if(DRL_ON && leftBlinkCount < 1 && rightBlinkCount < 1){
    drlLight();
  }

  blinkRight();
  blinkLeft();
  if(rightBlinkCount < 1 || leftBlinkCount < 1){
    delay(30);
    switch (LAST_COMMAND) {
      case 'q':
      case '?': {
        for ( int gp = 0; gp < NUMPIXELS + PIXELTOSHOW; gp++) {
          leftLight.setPixelColor(gp, COLOR_NON);
          rightLight.setPixelColor(gp, COLOR_NON);
        }
        leftLight.show();
        rightLight.show();
        G_PIXEL = -1;
        break;
      }
      case 's': {
        slideBlueRed();
        //Serial.println("bluuu");
        if (G_PIXEL >= NUMPIXELS ) {
          G_PIXEL = -1;
          switchRB = switchRB == 0 ? 1 : 0;
        }
        break;
      }
      case 'w': {
        welcome();
        if (G_PIXEL >= NUMPIXELS + PIXELTOSHOW) {
          G_PIXEL = -1;
        }
        break;
      }
      case 'd': {
        if(DRL_ON==false){
          D_PIXEL = DRL_STARTPIXEL;
          DRL_ON = true;
          LAST_COMMAND = '-';
        }else{
          D_PIXEL = 0;
          DRL_ON = false;
        }
        break;
      }
    }
    if (Serial.available()) {
      LAST_COMMAND = '-';
      while (Serial.available()) {
        char command = Serial.read();
        G_PIXEL=-1;
        LAST_COMMAND = command;
      }
    }
  }
}

Btw, ignore the case where 12V and 3.3V are tied together, The button can be used for only testing  and transistor was ment to be used in live connections.

Is that schematic completely accurate? Especially the bit where you have the - of a 3.3V source connected to the +3.3V pin of the Arduino?

Actually, sorry thought the prev scheme was messy, heres is what had as live and (one of the) test ENV. d.pr/i/BTxm I ran out of trial time in circuit lab and couldnt add the dirty test env. That is connecting the v3.3 directly to D2 with jumper wire.

Is R3 really 220Ω or is it bigger?

Anyway, now that I have seen the schematic I have more of an idea.  Your code uses D3 for a right-hand shift or something, yes? You don't have anything attached to D3?

no I just tested around with some resistors to see how they behave and of they work (not my strongest area hehe). yeah the D2 is for one stripe of neo pixels and d3 is another stripe, but when testing I only use one at a time, mostly it is d2

You need to hold your unused input in a known state (pull it to ground) otherwise it will be floating and will be randomly triggering and picking up noise from the surrounding - from things like your hand when it's near.

ahhhhaaaaa, that makes kind of sense, tho o never suspected D3 to cause this. I'll test that out tomorrow and add your solution as new post to make it as answer. and to you who have edited my original post with correct images thank you so much, am still horrible noob on overflow/exchange  inline coding

I guess those schematics helped after all.  Thanks for posting this question.  I'm a bit new to building proper digital circuits, and I can so see myself making a mistake like this.  This will make it easier to recognize.

This kind of behavior is almost always caused by floating digital input pins. "floating" means not connected to either power or ground, so their voltage is free to float. These input puts have very high impedance (typically less than 1uA of leakage current), so bringing a charged object near them is more enough to change their state.
Probably the easiest way to nail down (and sometimes fix) this problem is to enable the pull-up resistors on the digital inputs.
In you program, this could be as easy changing the mode on the digital input pins from INPUT to INPUT-PULLUP...
void setup() {
  Serial.begin(115200);
  leftLight.begin();
  rightLight.begin();
  pinMode(LEFT_BLINK_IN, INPUT_PULLUP );
  pinMode(RIGHT_BLINK_IN, INPUT_PULLUP );
  delay(50);
  welcome();
}

This will almost certainly eliminate the intermittent behavior you are seeing.
What you end up with might not be what you want (you might want the pin to dault to 0 when not connected), in which case you can add an external pull-down resistor or change the software to work with default pull-up.

Yah, seems the floating input was causing this behavior.

Now, 3 years later, I found the actual source of your problem. I had a similar problem so I'm posting here for others to find this solution.
The problem is that the NeoPixel library disables ALL interrupts during the time it spends sending the pixel data. The millis() function is dependent on interrupts. It works by incrementing a counter once every millisecond, based on a interrupt, called from a hardware timer. If you disable all interrupts then the counter will not be incremented for the duration.
The NeoPixel library needs to disable them because NeoPixels need very accurate timing of the signals, and you'd suffer from visible intermittent glitches if not.
The millis() counter drops about 30 microseconds per a RGB pixel, or 40 microseconds for a RGBW pixel. You have 54 RGB pixels in your led strip. 54*0,030 = 1,62 ms. Which means that there's 1,62 milliseconds between each of your millis() updates. I.e. it updates too slow.
Your unstable button must've simply caused nonstop neopixel updates, due to some logic in your code.
There's no easy fix for this, but a few specialized alternative or companion libraries exist that use very device-specific peripherals to work around it. For example, you could use one of the hardware timers to measure the time spent sending NeoPixel data, and then manually go in and update the millis() counter accordingly when done. This requires hacking the NeoPixel library and reading the datasheets for your specific Arduino processor.

Thanks for getting back with update, definitely good research you've done! Kudos!

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


text:
Buttons and LED
I am creating a program that turns on and off an led. When two buttons are considered "high". But there is a twist, The first button needs to stay "high" until the second button is pressed and the led turns on. Here is my code so far.
// Boolean logic for Button Switch
boolean currentState = LOW;    //stroage for current button state
boolean lastState = LOW;      //storage for last button state
boolean ifcondState = LOW;    //storage for the current state of the ifturn  (off/on)

// set pin numbers:
const int buttonPinA = 3;     // the number of the pushbutton pin
const int buttonPin1 = 4;     // the number of the pushbutton pin
const int ledPin =  13;      // the number of the LED pin
const int ifcond =  12;      // the number of the ifcond pin
const int ifturn =  11;      // the number of the ifturn pin

// variables will change:
int buttonStateA = 0;         // variable for reading the pushbutton status
int buttonState1 = 0;         // variable for reading the pushbutton status
int buttonStateIf = 0;         // variable for reading the If Condition status

void setup() {
//initialize Serial connection
Serial.begin(9600);
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPinA, INPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin1, INPUT);
// If Condictional Pin
pinMode(ifcond, OUTPUT);
// If Turnon Pin
pinMode(ifturn, INPUT);

}

void loop() {
  // read the state of the pushbutton values:
  currentState = digitalRead(buttonPinA);
  buttonState1 = digitalRead(buttonPin1);
  buttonStateIf = digitalRead(ifturn);

  // check if the pushbutton is pressed.
  // if it is, the buttonState is HIGH:
  if (currentState == HIGH && lastState == LOW){    //  if button has just been pressed
    Serial.println("pressed");
    //delay(1);

    //toggle the state of the ifcond
    if (ifcondState == HIGH){
      digitalWrite(ifcond, LOW);
      ifcondState = LOW;
    }
    else {
      digitalWrite(ifcond, HIGH);
      ifcondState = HIGH;
    }
  }
  lastState = currentState;

  if (ifturn == HIGH && buttonState1 == HIGH) {
    digitalWrite(ledPin, HIGH);
  }
  else ();
  digitalWrite(ledPin, LOW);
}

I have Pin 12 (ifcond) And pin 11(ifturn) Jumped together. Pin 12 acts like a button to pin 11, When it goes high pin 11 reads the change.
The code works like this, When ButtonpinA goes high  pin 12 goes high and stays high until the next button push. This is the part that doesn't work Pin 11 should read if pin 12 if high or not. If it reads high and Button1 is also high it should turn on ledpin which it does not.
I am sorry for any confusion Thanks

I can't understand what you want it to do. Also; else (); is rather odd. You also might want to look into debouncing the buttons.

I want to be able to press and release Button A and then be able to press button one whenever i want to turn the led on

if (ifturn == HIGH && buttonState1 == HIGH) {
  digitalWrite(ledPin, HIGH);
}
else ();
digitalWrite(ledPin, LOW);

I think you have made a small mistake here.
What you are saying there is "If both these inputs are high then turn on the LED - otherwise don't do anything", and immediately after that "Turn off the LED".
So the LED is turned on when they are both high, and immediately turned off again, so fast you never see the LED lighting up at all.
I think what you meant to have was:
if (ifturn == HIGH && buttonState1 == HIGH) {
  digitalWrite(ledPin, HIGH);
} else {
  digitalWrite(ledPin, LOW);
}

That way it will turn the LED on if both are HIGH, otherwise it will turn the LED off only if the test for both being high fails.


text:
Would Arduino Nano be good for Bluetooth + Sound
So I've been browsing around for a whole looking for a good microcontroller that's super small. So far the smallest one I found was an Arduino Nano. But before I go buying it, there are some questions I have about it.

Is Bluetooth compatible with it and if so where would I get the Bluetooth code?
Is there anything smaller than it that's Bluetooth compatible?
Would an Arduino Nano (Or the device in the question above) be able to play sounds?

There are Bluetooth boards and chips that you can connect to a Nano.
You can play sounds with a Nano. Crudely with PWM and a direct connection, for finely with an external digital-to-analog converter.
But if super-smallness is what you are after, there may be better options.
The Blue Bean is a complete  BLE microcontroller on a single board that is smaller than a Nano+board.
If you want even smaller, you could get something like the new Cypress EZ-BLE module...

http://www.cypress.com/products/ez-ble-module-bluetooth-smart
It is a complete programmable BLE system on a tiny module. It is hard to imagine anything smaller than that!

Can a blue bean connect to a Windows usb port @bigjosh

In theory, could this Cypress BLE module be grafted into an existing piece of consumer electronics (I'm thinking portable video games system) and wired up to deliver Bluetooth audio for wireless headphones? Assuming skills, space inside the device, access to appropriate connections for power and audio in...

@RowanHarley You'd typically use Bluetooth to connect to the blue bean, so you don't need a USB connection.

@MickWaites If you want to deliver audio over the connection, then you probably want Bluetooth rather than only BLE. Probably the easiest way to stream audio to some bluetooth headphones is to get one of these and take it apart to fit into your game system.


text:
Transistors to switch monitor inputs
I am using the following setup on my Arduino UNO to measure cpu fan RPMs:

The code is set to bring the trigger pin for each transistor high when it is checking that fan's RPM and FreqMeasure.h is then used to check the frequency of the signal on pin 8 which is then translated to RPM and sent to the LCD display.
I am experiencing reading issues and suspect that the signal is remaining on the measuring bus during the subsequent reads, however before revamping my code I simply wonder:
Is my circuit logic sturdy? I am just getting my feet back under me with microprocessors and have always found transistors to be a tricky subject, thanks in advance for your help!
If you'd like to see more info all can be found on GitHub.

I'm not sure I follow the logic of what your circuit is supposed to do. Why do you need the transistors - why don't you just have each fan's HE output connected to its own input pin with a pullup resistor on each one?

I have setup as such because the FreqMonitor.h library only reads on Pin 8. (edit: for the UNO, it is a different pin on each model iirc)

Ok, that's fair enough then.

I am experiencing reading issues - can you be more specific? What happens compared to what you expected to happen? What does your debugging output tell you?

I have a post about analog multiplexers which may be a simple solution compared to the transistors.

I have simulated your circuit and it seems sound enough to me.
It is a little confusing having the transistors there though.  I would prefer to convert the three open drain outputs to logic level outputs (each having its own pullup resistor) then use a digital 3:1 MUX (or discrete logic gates) to select the signal to sample.

Thanks for your answer! And definite thanks for that simulation! I wasn't aware of this tool, definitely bookmarked. As I'm seeing, my method is essentially a MUX, just without using logic gates.  However a discrete MUX chip will definitely be on my consideration list.

Do you have a datasheet that says the A1301UA has an open drain output? The file A1301-2-Datasheet.pdf says the A1301 outputs are  ratiometric, increasing 2.5 mV per Gauss.  Its working voltage is about 5 V, with abs max 8 V.

The A1301 was just being used as a place holder for an actual open drain output.


text:
How to connect this motor driver board to Arduino to drive bidirectional motor?
I am familiar with using PWM on Arduino and have done so with simple 3-pin interfaces: e.g. PWM, DIR (direction) and GND pins. Choose a direction with DIR, set speed with PWM in software (0 - 255), simple stuff.
But this board I'm buying seems different:
http://www.ebay.com/itm/DC-43A-Double-BTS7960B-Stepper-Motor-Driver-H-Bridge-PWM-for-Arduino-Smart-Car-/141485439094
There seems to be 6 control pins:
R_IS, R_EN, RPWM, L_IS, L_EN, LPWM
But from what I understand this board would only be used for controlling one motor bidirectionally, so why is there a distinction between left and right?
So how would I go about using this motor driver board in a similar way to my PWM, DIR, GND boards that I've used before to control the motor direction and speed?
Thanks!

I guess you have used DC Motor for your earlier cases? Or Step Motor with a logic on the stepper controllers?
Here you have two H Bridges which drives one Step Motor. So as I understand it, you have two PWM Inputs, one for each output channel to the coil windings of the stepper motor. Like an encoder signal you can set the direction with setting one pwm before the other. So the step motor is controlled via unipolar stepping.
For further help you need to say which motor you want to use with this card. But first I would look at the different stepping modes (unipolar and the two bipolar and maybe microstepping).
Greets

Thanks for responding. I have no idea about steppers and don't plan on using one. Rather I use a DC gear motor like this: https://www.servocity.com/html/23_rpm_hd_precision_planetary_.html#.VfiKyRFViko My goal is to be able to control its speed and direction with this board if possible.

I think this tutorial shows what I want to do: http://www.instructables.com/id/Motor-Driver-BTS7960-43A/step2/Connect-It-To-The-arduino/


text:
USB mini type B port on Arduino Uno
I bought today an Arduino Uno R3, and I'm looking forward to make it an HID device. I have seen many projects using a serial USB type B port. As I want to build a little gamepad, I would like to use the smaller USB mini type B port to achieve similar results. Looking it up did not seem to bring significant results.
Am I missing anything? Do I have to use a serial port similar to the one used by Arduino or can I reproduce the project using the aforementioned port?

Is it an Uno or an Uno R3?

The connector is just a connector. They carry the same signals - 5V, GND, D+ and D-.  By the way, how do you intend to make your Uno a HID device? And what does the connector (which is soldered to the board) have to do with it?

According to this video - https://www.youtube.com/watch?v=RoG_-9lAnSI - it can be done with the use of a serial port and a few other components
It is an Uno R3

Ah - software bit-banged USB.  Nasty.  Much better off re-programming the 32U4 chip to do proper USB.

I could be interested in such a method, what could it mean? Would i still be able to program it like a normal Arduino?

Just use a Mini type B to Standard type B adapter, if so required. It will pass the data lines through correctly.

It sounds like you are going to be attempting software "bit-banged" USB.  That, while possible, is severely frowned upon, especially when you have the resources to do it properly at your fingertips.
In answer to your question, yes, you can use a USB mini B connector.  It is no different to a USB B connector except it is much smaller and contains one extra pin - USBID - which you can completely ignore (it's only used on USB On-The-Go devices).
USB is quite a heavy protocol to do in pure software - it won't leave much "room" for you to do much else.  Better would be to re-program the ATMega16U2 chip that is used for the current USB interface.  You will need some form of hardware programmer for it - you can use another Arduino Uno, and once done you won't be able to directly program the ATMega328P chip through the USB, so you would need some other method for connecting that (external USB serial adapter cable, or another Arduino), but the ATMega16U2 chip is specifically designed to work with the USB.  Offloading the USB portion of your project onto that chip and using the serial interface that is already wired up to communicate commands and instructions to/from the ATMega328P would be a much more powerful (and reliable) system.  There's plenty of tutorials and links around to show you how to reprogram that chip.

i actually only wanted to know if it was possible to use the USB mini connector. I can see now that this setup is not the best solution for sending keypresses (or input in general) to a computer, but i'm okay with it for now. I am still a newbie so reprogramming the chip may be a bit over my capabilities, so for a better implementation of my project i will look into buying an Arduino Due, Leonardo, or something else, depending on my needs. The answer is therefore accepted.

It's an ATmega16U2 on the Uno, @Majenko. See Arduino / Genuino UNO.

@Nick I always get them mixed up. I know it changed from the R2 to the R3 and I never remember which it changed from / to. I though it went from 16U2 to 32U4 but maybe it went from 8U2 to 16U2.

Yep I think it went from a 8U2 to a 16U2. I can never remember, either, I always have to look it up. :)

As an alternative to Majenko's suggestion you can implement Virtual USB as described at Virtual USB Keyboard. You just need:

3 resistors
2 zener diodes
a bit of wire
a suitable USB socket

The advantage is you haven't modified your Uno's USB chip (the ATMega16U2) so you can continue to upload sketches in the normal way.
The disadvantage is that the software USB may be more flaky than a hardware-implemented one.
Personally I don't like reprogramming my ATMega16U2 because I may as well have used one of the chips with a ATmega32U4 chip on it in the first place (like the Micro) which is designed for easy reprogramming.

That solution is the one i found to be the easier. I already linked to a video in one of my comments above.


text:
Comparators for digital input mode
I've asked another question in electronics about what to use to compare 2 input voltages, the answer was to use comparators.
Digging around a bit, turns out most of the comparators outputs are pull-up, which makes it quite difficult to translate (probably due lack of general electronics knowledge, self-learned) and I'm not able to distinguish from maker's PDFs which comparators have pull-up or pull-down outputs.
I've figured PD comparators illustrate in PDF a resistor right after the output... but many illustrations I've seen doesn't clarify PD / PU, or I'm just missig that.
But my question is, are there any PD comparators (well known) where it's output can be connected to the digital pins or arduino (while those are defined as INPUT mode)?
I appreciate any guidance on this topic.
Just a side note, I want to switch on a led, when ever external source is at 12V and turn that same led off when it's below 11.5V...

You can't put 12 volts into a Uno input pin in any case.
You could run it into a voltage divider and divide it down to somewhere on the range 0 to 5 V, and then do an analogRead to see exactly (or almost exactly) what the resulting voltage is.
I don't really see where comparators come into it in this particular case. I mean, you could use a comparator to turn the LED on, but then where does the Arduino come into it?

I've actually tried with voltage divider, I went pretty high on my resistors, taking the 12V source and hooked in 4x1M resistors but the 12V never came down significantly.

You need a voltage divider like this:

Those values give you 4 V on the Arduino pin if there is 12 V on the input.
Vout = (R2 / (R1 + R2) ) * Vin
So:
(1000 / 3000) * 12V = 4V

Perhaps the 12Vs don't have to do anything with the comparator. It does not read like it is related.

You could be right, but I read I want to switch on a led, when ever external source is at 12V and turn that same led off when it's below 11.5V... as the purpose for the comparator.

I was guided towards comparator since the external source is signal turning light in vehicle at it seems to output 12v as active and 11v (or close to 11v, +-0.5v) as inactive signal into the lightbulb. tho I suspect that there is some module that listens to these voltages and gives either 0 or 12v to the actual bulb but I'm unable to take apart that headlight to confirm that.

Ive actually tried with voltage divider, i went pretty high on my resistors, taking the 12V source and hooked in 4x1M resistors but the 12V never came down significantly. I also tested out with few lower resistors like mutiple 100K, also with multiple 4K7 (all in series) but i only got 6V as lowest and 9V as highest (also that 9V sometimes peaked up to 11V). I did try to add more and more resistors to bring the 10V/12V scale down for arduino to handle but it never succeeded.

You aren't doing it correctly then. Two resistors are all you need. A voltage divider does not work by having a lot of 1 M resistors in series. You need two resistors only, and tap into the junction between them. For example, a 2 k and a 1 k would divide 12 V down to 4 V. See voltage divider calculator. Look carefully at how they are wired.

Many comparators come with open collector output. OC output means, it can pull down a potential, but cannot generate a voltage higher than ground.
If you have a high impedance input like your Arduino has, and you connect a OC output to it, nothing will happen unless you add a pullup resistor providing a positive voltage. Otherwise there won't be a closed electric circuit where any measurable voltages can be generatet.
Lucky you: Arduino input pins can generate a positive voltage by providing an internal pullup resistor. Read the documentation on input pins and pin direction to make use of this. This way you can connect an open collector output to your input pin without additional components.
But beware: This doesn't work with a comparator with a pullup output (I guess these are rather rare). In this case you have to provide an additional pulldown resistor to ground.
Caveat: You can use a comparator with totem pole or tristate output without pullup or down as long as its output swing does not exceed maximum allowable voltages of the input pin. I.e. you cannot connect a comparator supplied with 15 V and a totem pole output to the input of an arduino, because the high level will exceed 5 volts (I assume an Arduino Uno).
Now. How to learn from a datasheet, if the output is pulldown, pullup, totempole or tristate?
If a device features a pulldown stage, you will find a value for something called "Output Sink Current" in the section "electrical characteristics". For a pulldown stage this will likely be named "Output source current". A tristate output will be denominated somewhere in the datasheet for sure, because this is an extra feature.
Have a look at lm339!

thank you for really good explanation, will check it out with PDFs. the reason to arduino is this led is actually neo pixel, and in arduino î have multiple animations for these pixels


text:
SIM900 AT command HTTP GET request not show the web page
I build a simple HTTP GET request by SIM900. Here is it:
-----1-----
AT+CSQ

+CSQ: 25,0

OK

-----2-----
AT+CGATT?

+CGATT: 1

OK

-----3-----
AT+SAPBR=3,1,"CONTYPE","GPRS"

OK

-----4-----
AT+SAPBR=3,1,"APN","indosatgprs"

OK

-----5-----
AT+SAPBR=1,1

OK

-----6-----
AT+HTTPINIT

ERROR

-----6.1-----
AT+HTTPPARA="CID",1

OK

-----7-----
AT+HTTPPARA="URL","http://www.minimalsites.com"

OK

-----8-----
AT+HTTPACTION=0

OK

-----9-----
AT+HTTPREAD

OK

-----10-----
AT+HTTPTERM

ERROR

+HTTPACTION:0,200,1240

-----10.0-----
AT+SAPBR=0,1

OK

The step 9 AT+HTTPREAD I supposed to see some html from http://www.minimalsites.com. But i dont see anything, What wrong with me?

Before you do anything HTTP you should do a "AT+SAPBR=2,1" and see if you are actually connected to the bearer. It should return "+SAPBR: 1,1,aa.bb.cc.dd"

It return +SAPBR: 1,3,"0.0.0.0". What is that said?

That means you are not connected.

From what I can see in your results, it seems AT+HTTPINIT returned an error. This means the HTTP service wasn't even successfully activated. So there's no way the commands you issued later would have been successful. From the AT command manual, AT+HTTPINIT is necessary before you can do any HTTP-related stuff.
You need to run the command AT+CGATT=1 to attach GPRS, even if your query shows its value is already 1.
It could also be that your APN requires authentication, using a username and password. So once you find out the username and password authorized by 'indosatgprs' (customer care?), you can use them in the following commands.
    AT+SAPBR=3,1,"USER","Enter the username here"
    AT+SAPBR=3,1,"PWD","Enter password"

Both commands should return OK if successful. To view all the parameters you have set, you can use AT+SAPBR=4,1. If all the parameters are satisfactory, and you have sufficient airtime in the SIM, then you can attempt AT+HTTPINIT. Only if this command returns OK, should you proceed to run AT+HTTPPARA-related commands.

Check Your Connection Try Pinging the IP of Your Arduino and INstead of Using the AT commands use this library its easier and Nice https://github.com/amcewen/HttpClient

how to know my IP address? my device run by SIM card

You have to wait after AT+HTTPACTION=0 for a while until you see something like +HTTPACTION:0,200,1240
Then continue to AT+HTTPREAD, you will see the result.
Finally, terminate HTTP.

after days fighting with asynchronous and limit serial buffer size (64Bytes). I found this one.
this link help me out, it uses the standard library SoftwareSerial and my big txt file 1100 bytes or my html file (5814bytes)  are  download again & again with no issue!!
https://www.youtube.com/watch?v=cpgQOmQwUL8&t=1263s
http://www.iforce2d.net/sketches/gsm_HTTPGet.zip
nb: I change it to AltSoftSerial, no problem neither.
Thanks iforce2d
ps: you can also use the "ModuleSerial-master" library, but I need to save the space for other code (which already uses 74% of 2KB RAM) so I stick to AltSoftSerial which already found in my sketch


text:
How I can print several numbers via Serial with very few lines of code?
Could someone help me how to output the numbers from 1 to 10 via Serial, without having to write out each command by hand?
Below is my sketch - I need it concise instead of a long sketch:
#include <Streaming.h
//setup
void setup() {
 Serial. begin(9600);//The faster the better
}//Close the sertup

//main loop
void loop() {

  Serial<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<< endl;
  Serial<<"\t"<<"\t"<<"\t"<<"\t"<<"\t"<< _DEC(1) << endl;
  delay(1000);
  Serial<< _BYTE(27)<< _BYTE(91)<< _BYTE(50)<< _BYTE(74);//CLR
  Serial<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<< endl;
  Serial<<"\t"<<"\t"<<"\t"<<"\t"<<"\t"<< _DEC(2) << endl;
  delay(1000);
  Serial << _BYTE(27)<< _BYTE(91)<< _BYTE(50)<< _BYTE(74);//CLR
  Serial<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<< endl;
  Serial<<"\t"<<"\t"<<"\t"<<"\t"<<"\t"<< _DEC(3) << endl;
  delay(1000);
  Serial << _BYTE(27)<< _BYTE(91)<< _BYTE(50)<< _BYTE(74);//CLR
  Serial<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<< endl;
  Serial<<"\t"<<"\t"<<"\t"<<"\t"<<"\t"<< _DEC(4) << endl;
  delay(1000);
  Serial << _BYTE(27)<< _BYTE(91)<< _BYTE(50)<< _BYTE(74);//CLR
  Serial<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<< endl;
  Serial<<"\t"<<"\t"<<"\t"<<"\t"<<"\t"<< _DEC(5) << endl;
  delay(1000);
  Serial << _BYTE(27)<< _BYTE(91)<< _BYTE(50)<< _BYTE(74);//CLR
  Serial<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<< endl;
  Serial<<"\t"<<"\t"<<"\t"<<"\t"<<"\t"<< _DEC(6) << endl;
  delay(1000);
  Serial << _BYTE(27)<< _BYTE(91)<< _BYTE(50)<< _BYTE(74);//CLR
  Serial<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<< endl;
  Serial<<"\t"<<"\t"<<"\t"<<"\t"<<"\t"<< _DEC(7) << endl;
  delay(1000);
  Serial << _BYTE(27)<< _BYTE(91)<< _BYTE(50)<< _BYTE(74);//CLR
  Serial<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<< endl;
  Serial<<"\t"<<"\t"<<"\t"<<"\t"<<"\t"<< _DEC(8) << endl;
  delay(1000);
  Serial << _BYTE(27)<< _BYTE(91)<< _BYTE(50)<< _BYTE(74);//CLR
  Serial<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<< endl;
  Serial<<"\t"<<"\t"<<"\t"<<"\t"<<"\t"<< _DEC(9) << endl;
  delay(1000);
  Serial << _BYTE(27)<< _BYTE(91)<< _BYTE(50)<< _BYTE(74);//CLR
  Serial<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<< endl;
  Serial<<"\t"<<"\t"<<"\t"<<"\t"<<"\t"<< _DEC(10) << endl;
  delay(1000);
  Serial << _BYTE(27)<< _BYTE(91)<< _BYTE(50)<< _BYTE(74);//CLR
  Serial<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<< endl;
  Serial<<"\t"<<"\t"<<"\t"<<"\t"<<"\t"<< _DEC(11) << endl;
  delay(1000);
  Serial << _BYTE(27)<< _BYTE(91)<< _BYTE(50)<< _BYTE(74);//CLR
  Serial<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<< endl;
  Serial<<"\t"<<"\t"<<"\t"<<"\t"<<"\t"<< _DEC(12) << endl;
  delay(1000);
  Serial << _BYTE(27)<< _BYTE(91)<< _BYTE(50)<< _BYTE(74);//CLR
  Serial<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<< endl;
  Serial<<"\t"<<"\t"<<"\t"<<"\t"<<"\t"<< _DEC(13) << endl;
  delay(1000);
  Serial << _BYTE(27)<< _BYTE(91)<< _BYTE(50)<< _BYTE(74);//CLR
  Serial<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<< endl;
  Serial<<"\t"<<"\t"<<"\t"<<"\t"<<"\t"<< _DEC(14) << endl;
  delay(1000);
  Serial << _BYTE(27)<< _BYTE(91)<< _BYTE(50)<< _BYTE(74);//CLR
  Serial<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<< endl;
  Serial<<"\t"<<"\t"<<"\t"<<"\t"<<"\t"<< _DEC(15) << endl;
  delay(1000);
  Serial << _BYTE(27)<< _BYTE(91)<< _BYTE(50)<< _BYTE(74);//CLR
  Serial<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<< endl;
  Serial<<"\t"<<"\t"<<"\t"<<"\t"<<"\t"<< _DEC(16) << endl;
  delay(1000);
  Serial << _BYTE(27)<< _BYTE(91)<< _BYTE(50)<< _BYTE(74);//CLR
  Serial<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<< endl;
  Serial<<"\t"<<"\t"<<"\t"<<"\t"<<"\t"<< _DEC(17) << endl;
  delay(1000);
  Serial << _BYTE(27)<< _BYTE(91)<< _BYTE(50)<< _BYTE(74);//CLR
  Serial<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<< endl;
  Serial<<"\t"<<"\t"<<"\t"<<"\t"<<"\t"<< _DEC(18) << endl;
  delay(1000);
  Serial << _BYTE(27)<< _BYTE(91)<< _BYTE(50)<< _BYTE(74);//CLR
  Serial<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<< endl;
  Serial<<"\t"<<"\t"<<"\t"<<"\t"<<"\t"<< _DEC(19) << endl;
  delay(1000);
  Serial << _BYTE(27)<< _BYTE(91)<< _BYTE(50)<< _BYTE(74);//CLR
  Serial<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<< endl;
  Serial<<"\t"<<"\t"<<"\t"<<"\t"<<"\t"<< _DEC(20) << endl;
   delay(1000);
  while(1){}//freeze the main loop

}

Where is the photo?

It is better to post the code, not photograph a screen with it on. Just copy the code from your sketch, edit your post, and post it into it. Select the code and hit Ctrl+K to indent it, and make it look nice.

The faster the better - how about 115200 baud then?

Can you tell me how to add my code here?

Edit your question (Click "edit"). Copy the code from your sketch and paste it into the question. Then select the code and hit Ctrl+K to indent it and make it look like code.

I have just did it, can you check it please

Sorry Nick my English not very well and I don't have experience in this website

I have tried many time to use your code but it doesn't work I don't know why, anyway this is my code and I hope you write it shorter then mine.

[This replaces my earlier answer, and addresses information added to the question.]
You apparently want a sketch that outputs 1, 2, 3 ... 100 to serial output, where each number string is embedded within a control sequence.
Here are two ways.  The first program outputs the sequence once, using ordinary Arduino Serial.write(), Serial.print() and Serial.println() statements:
Program 1.  Output 1, 2, 3 ... 100 once
void setup() {
  Serial.begin(9600);
  for (int j=1; j<=100; ++j) {
    Serial.write(27); // Send escape character
    Serial.print("[2J"); // Send erase-screen command
    Serial.print("\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t");
    Serial.println(j); // Send j in decimal format
    delay(1000);
  }
}
void loop() {}

The other program will output the sequence repeatedly.  It uses the Streaming.h library, but in a  rational manner; for example, instead of quoting every character separately like the program in the photo, it quotes character sequences in strings.  Note, Esc [2J is an ANSI escape code sequence that erases the screen it is directed to, if the screen device is ANSI compliant.
Program 2.  Output 1, 2, 3 ... 100 repeatedly
#include <Streaming.h> // or "Streaming.h" if appropriate
byte j=0;
void setup() {
  Serial.begin(9600);
}
void loop() {
  ++j;
  // Send Esc [2J which will erase screen
  Serial << _BYTE(27) << "[2J";
  Serial << "\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t" << j;
  if (j >= 100) j=0;
  delay(1000);
}

Yasir, I added a } that was missing, and also added delay(1000);.  When you say  “I have tried many time to use your code but it doesn't work” are you referring to Nick's code, or to one of my programs above?  What happens when you compile and upload the code?

Thank you so so much I really appreciate your help, I have just copy your code and it works very well.;-)

Ah, a challenge!

I have to write from 1 to 100, and I don't want to repeat it all 100 times

Your question did not make that clear. Anyway:
int main () {
  Serial.begin (9600);
  for (int i = 1; i <= 100; i++)
    Serial.println (i);
  while (true);
  }

You can probably make it shorter at the expense of readability.
int main(){Serial.begin(9600);for(int i=1;i<=100;i++)Serial.println(i);while(1);}

Ah, a challenge!
I have to write from 1 to 100, and I don't want to repeat it all 100 times
Your question did not make that clear. Anyway:
int main () {
Serial.begin (9600);
for (int i = 1; i <= 100; i++)
Serial.println (i);
while (true);
}
You can probably make it shorter at the expense of readability.
int main(){Serial.begin(9600);for(int i=1;i<=100;i++)Serial.println(i);while(1);}. If I use this way, the number will count automatically from 1 to 10 ?

You don't need to copy and paste my entire answer into your comment. That is just very confusing. If I use this way, the number will count automatically from 1 to 10 - well you said 100 in your comment ("I have to write from 1 to 100"). Try to pay attention when you are typing. Asking for 10/100/10 is really confusing. Yes, that is what a for loop does. You may want to read a tutorial on C programming. Copying and pasting 100 times is not what your teacher had in mind, I bet.

Nick,  where you say int main (), was that intentional, or did you mean to have void setup()  ?

It was intentional in the spirit of keeping it "short". Doing a main means you don't need both setup and loop, and is more in-line with standard C programming. You do, of course, need to also call init() if you expect to use timers, delay() and so on.

Hi guys. I have tried many time to use your code but it doesn't work I don't know why, anyway this is my code and I hope you write it shorter then mine.

It worked when I tested it. In what way does it not work for you? Compiler error? Wrong numbers shown? No numbers? Please be specific.

Fixing the typos in your original code, so that it should probably read:
#include <Streaming.h>

//setup
void setup() {
 Serial.begin(9600);  //The faster the better
}   //Close the setup

//main loop
void loop() {
  Serial<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<< endl;
  Serial<<"\t"<<"\t"<<"\t"<<"\t"<<"\t"<< _DEC(1) << endl;
  delay(1000);
  Serial<< _BYTE(27)<< _BYTE(91)<< _BYTE(50)<< _BYTE(74);//CLR
  Serial<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<< endl;
  Serial<<"\t"<<"\t"<<"\t"<<"\t"<<"\t"<< _DEC(2) << endl;
  delay(1000);
  Serial << _BYTE(27)<< _BYTE(91)<< _BYTE(50)<< _BYTE(74);//CLR
  Serial<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<< endl;
  Serial<<"\t"<<"\t"<<"\t"<<"\t"<<"\t"<< _DEC(3) << endl;
  delay(1000);
  Serial << _BYTE(27)<< _BYTE(91)<< _BYTE(50)<< _BYTE(74);//CLR
  Serial<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<< endl;
  Serial<<"\t"<<"\t"<<"\t"<<"\t"<<"\t"<< _DEC(4) << endl;
  delay(1000);
  Serial << _BYTE(27)<< _BYTE(91)<< _BYTE(50)<< _BYTE(74);//CLR
  Serial<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<< endl;
  Serial<<"\t"<<"\t"<<"\t"<<"\t"<<"\t"<< _DEC(5) << endl;
  delay(1000);
  Serial << _BYTE(27)<< _BYTE(91)<< _BYTE(50)<< _BYTE(74);//CLR
  Serial<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<< endl;
  Serial<<"\t"<<"\t"<<"\t"<<"\t"<<"\t"<< _DEC(6) << endl;
  delay(1000);
  Serial << _BYTE(27)<< _BYTE(91)<< _BYTE(50)<< _BYTE(74);//CLR
  Serial<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<< endl;
  Serial<<"\t"<<"\t"<<"\t"<<"\t"<<"\t"<< _DEC(7) << endl;
  delay(1000);
  Serial << _BYTE(27)<< _BYTE(91)<< _BYTE(50)<< _BYTE(74);//CLR
  Serial<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<< endl;
  Serial<<"\t"<<"\t"<<"\t"<<"\t"<<"\t"<< _DEC(8) << endl;
  delay(1000);
  Serial << _BYTE(27)<< _BYTE(91)<< _BYTE(50)<< _BYTE(74);//CLR
  Serial<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<< endl;
  Serial<<"\t"<<"\t"<<"\t"<<"\t"<<"\t"<< _DEC(9) << endl;
  delay(1000);
  Serial << _BYTE(27)<< _BYTE(91)<< _BYTE(50)<< _BYTE(74);//CLR
  Serial<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<< endl;
  Serial<<"\t"<<"\t"<<"\t"<<"\t"<<"\t"<< _DEC(10) << endl;
  delay(1000);
  Serial << _BYTE(27)<< _BYTE(91)<< _BYTE(50)<< _BYTE(74);//CLR
  Serial<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<< endl;
  Serial<<"\t"<<"\t"<<"\t"<<"\t"<<"\t"<< _DEC(11) << endl;
  delay(1000);
  Serial << _BYTE(27)<< _BYTE(91)<< _BYTE(50)<< _BYTE(74);//CLR
  Serial<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<< endl;
  Serial<<"\t"<<"\t"<<"\t"<<"\t"<<"\t"<< _DEC(12) << endl;
  delay(1000);
  Serial << _BYTE(27)<< _BYTE(91)<< _BYTE(50)<< _BYTE(74);//CLR
  Serial<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<< endl;
  Serial<<"\t"<<"\t"<<"\t"<<"\t"<<"\t"<< _DEC(13) << endl;
  delay(1000);
  Serial << _BYTE(27)<< _BYTE(91)<< _BYTE(50)<< _BYTE(74);//CLR
  Serial<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<< endl;
  Serial<<"\t"<<"\t"<<"\t"<<"\t"<<"\t"<< _DEC(14) << endl;
  delay(1000);
  Serial << _BYTE(27)<< _BYTE(91)<< _BYTE(50)<< _BYTE(74);//CLR
  Serial<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<< endl;
  Serial<<"\t"<<"\t"<<"\t"<<"\t"<<"\t"<< _DEC(15) << endl;
  delay(1000);
  Serial << _BYTE(27)<< _BYTE(91)<< _BYTE(50)<< _BYTE(74);//CLR
  Serial<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<< endl;
  Serial<<"\t"<<"\t"<<"\t"<<"\t"<<"\t"<< _DEC(16) << endl;
  delay(1000);
  Serial << _BYTE(27)<< _BYTE(91)<< _BYTE(50)<< _BYTE(74);//CLR
  Serial<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<< endl;
  Serial<<"\t"<<"\t"<<"\t"<<"\t"<<"\t"<< _DEC(17) << endl;
  delay(1000);
  Serial << _BYTE(27)<< _BYTE(91)<< _BYTE(50)<< _BYTE(74);//CLR
  Serial<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<< endl;
  Serial<<"\t"<<"\t"<<"\t"<<"\t"<<"\t"<< _DEC(18) << endl;
  delay(1000);
  Serial << _BYTE(27)<< _BYTE(91)<< _BYTE(50)<< _BYTE(74);//CLR
  Serial<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<< endl;
  Serial<<"\t"<<"\t"<<"\t"<<"\t"<<"\t"<< _DEC(19) << endl;
  delay(1000);
  Serial << _BYTE(27)<< _BYTE(91)<< _BYTE(50)<< _BYTE(74);//CLR
  Serial<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<< endl;
  Serial<<"\t"<<"\t"<<"\t"<<"\t"<<"\t"<< _DEC(20) << endl;
  delay(1000);
  while(1){} //freeze the main loop
}

Then condensing the cursor positioning lines, gives:
#include <Streaming.h>

//setup
void setup() {
 Serial.begin(9600);  //The faster the better
}   //Close the setup

//main loop
void loop() {
  Serial << "\n\n\n\n\n\n\n\n\n\n" << endl;
  Serial << "\t\t\t\t\t" << _DEC(1) << endl;
  delay(1000);
  Serial << _BYTE(27) << _BYTE(91) << _BYTE(50) << _BYTE(74); //CLR
  Serial << "\n\n\n\n\n\n\n\n\n\n" << endl;
  Serial << "\t\t\t\t\t" << _DEC(2) << endl;
  delay(1000);
  Serial << _BYTE(27) << _BYTE(91) << _BYTE(50) << _BYTE(74); //CLR
  Serial << "\n\n\n\n\n\n\n\n\n\n" << endl;
  Serial << "\t\t\t\t\t" << _DEC(3) << endl;
  delay(1000);
  Serial << _BYTE(27) << _BYTE(91) << _BYTE(50) << _BYTE(74); //CLR
  Serial << "\n\n\n\n\n\n\n\n\n\n" << endl;
  Serial << "\t\t\t\t\t" << _DEC(4) << endl;
  delay(1000);
  Serial << _BYTE(27) << _BYTE(91) << _BYTE(50) << _BYTE(74); //CLR
  Serial << "\n\n\n\n\n\n\n\n\n\n" << endl;
  Serial << "\t\t\t\t\t" << _DEC(5) << endl;
  delay(1000);
  Serial << _BYTE(27) << _BYTE(91) << _BYTE(50) << _BYTE(74); //CLR
  Serial << "\n\n\n\n\n\n\n\n\n\n" << endl;
  Serial << "\t\t\t\t\t" << _DEC(6) << endl;
  delay(1000);
  Serial << _BYTE(27) << _BYTE(91) << _BYTE(50) << _BYTE(74); //CLR
  Serial << "\n\n\n\n\n\n\n\n\n\n" << endl;
  Serial << "\t\t\t\t\t" << _DEC(7) << endl;
  delay(1000);
  Serial << _BYTE(27) << _BYTE(91) << _BYTE(50) << _BYTE(74); //CLR
  Serial << "\n\n\n\n\n\n\n\n\n\n" << endl;
  Serial << "\t\t\t\t\t" << _DEC(8) << endl;
  delay(1000);
  Serial << _BYTE(27) << _BYTE(91) << _BYTE(50) << _BYTE(74); //CLR
  Serial << "\n\n\n\n\n\n\n\n\n\n" << endl;
  Serial << "\t\t\t\t\t" << _DEC(9) << endl;
  delay(1000);
  Serial << _BYTE(27) << _BYTE(91) << _BYTE(50) << _BYTE(74); //CLR
  Serial << "\n\n\n\n\n\n\n\n\n\n" << endl;
  Serial << "\t\t\t\t\t" << _DEC(10) << endl;
  delay(1000);
  Serial << _BYTE(27) << _BYTE(91) << _BYTE(50) << _BYTE(74); //CLR
  Serial << "\n\n\n\n\n\n\n\n\n\n" << endl;
  Serial << "\t\t\t\t\t" << _DEC(11) << endl;
  delay(1000);
  Serial << _BYTE(27) << _BYTE(91) << _BYTE(50) << _BYTE(74); //CLR
  Serial << "\n\n\n\n\n\n\n\n\n\n" << endl;
  Serial << "\t\t\t\t\t" << _DEC(12) << endl;
  delay(1000);
  Serial << _BYTE(27) << _BYTE(91) << _BYTE(50) << _BYTE(74); //CLR
  Serial << "\n\n\n\n\n\n\n\n\n\n" << endl;
  Serial << "\t\t\t\t\t" << _DEC(13) << endl;
  delay(1000);
  Serial << _BYTE(27) << _BYTE(91) << _BYTE(50) << _BYTE(74); //CLR
  Serial << "\n\n\n\n\n\n\n\n\n\n" << endl;
  Serial << "\t\t\t\t\t" << _DEC(14) << endl;
  delay(1000);
  Serial << _BYTE(27) << _BYTE(91) << _BYTE(50) << _BYTE(74); //CLR
  Serial << "\n\n\n\n\n\n\n\n\n\n" << endl;
  Serial << "\t\t\t\t\t" << _DEC(15) << endl;
  delay(1000);
  Serial << _BYTE(27) << _BYTE(91) << _BYTE(50) << _BYTE(74); //CLR
  Serial << "\n\n\n\n\n\n\n\n\n\n" << endl;
  Serial << "\t\t\t\t\t" << _DEC(16) << endl;
  delay(1000);
  Serial << _BYTE(27) << _BYTE(91) << _BYTE(50) << _BYTE(74); //CLR
  Serial << "\n\n\n\n\n\n\n\n\n\n" << endl;
  Serial << "\t\t\t\t\t" << _DEC(17) << endl;
  delay(1000);
  Serial << _BYTE(27) << _BYTE(91) << _BYTE(50) << _BYTE(74); //CLR
  Serial << "\n\n\n\n\n\n\n\n\n\n" << endl;
  Serial << "\t\t\t\t\t" << _DEC(18) << endl;
  delay(1000);
  Serial << _BYTE(27) << _BYTE(91) << _BYTE(50) << _BYTE(74); //CLR
  Serial << "\n\n\n\n\n\n\n\n\n\n" << endl;
  Serial << "\t\t\t\t\t" << _DEC(19) << endl;
  delay(1000);
  Serial << _BYTE(27) << _BYTE(91) << _BYTE(50) << _BYTE(74); //CLR
  Serial << "\n\n\n\n\n\n\n\n\n\n" << endl;
  Serial << "\t\t\t\t\t" << _DEC(20) << endl;
  delay(1000);
  while(1){} //freeze the main loop
}

Then joining the two cursor positioning lines, gives:
#include <Streaming.h>

//setup
void setup() {
 Serial.begin(9600);  //The faster the better
}   //Close the setup

//main loop
void loop() {
  Serial << "\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t" << _DEC(1) << endl;
  delay(1000);
  Serial << _BYTE(27) << _BYTE(91) << _BYTE(50) << _BYTE(74); //CLR
  Serial << "\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t" << _DEC(2) << endl;
  delay(1000);
  Serial << _BYTE(27) << _BYTE(91) << _BYTE(50) << _BYTE(74); //CLR
  Serial << "\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t" << _DEC(3) << endl;
  delay(1000);
  Serial << _BYTE(27) << _BYTE(91) << _BYTE(50) << _BYTE(74); //CLR
  Serial << "\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t" << _DEC(4) << endl;
  delay(1000);
  Serial << _BYTE(27) << _BYTE(91) << _BYTE(50) << _BYTE(74); //CLR
  Serial << "\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t" << _DEC(5) << endl;
  delay(1000);
  Serial << _BYTE(27) << _BYTE(91) << _BYTE(50) << _BYTE(74); //CLR
  Serial << "\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t" << _DEC(6) << endl;
  delay(1000);
  Serial << _BYTE(27) << _BYTE(91) << _BYTE(50) << _BYTE(74); //CLR
  Serial << "\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t" << _DEC(7) << endl;
  delay(1000);
  Serial << _BYTE(27) << _BYTE(91) << _BYTE(50) << _BYTE(74); //CLR
  Serial << "\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t" << _DEC(8) << endl;
  delay(1000);
  Serial << _BYTE(27) << _BYTE(91) << _BYTE(50) << _BYTE(74); //CLR
  Serial << "\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t" << _DEC(9) << endl;
  delay(1000);
  Serial << _BYTE(27) << _BYTE(91) << _BYTE(50) << _BYTE(74); //CLR
  Serial << "\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t" << _DEC(10) << endl;
  delay(1000);
  Serial << _BYTE(27) << _BYTE(91) << _BYTE(50) << _BYTE(74); //CLR
  Serial << "\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t" << _DEC(11) << endl;
  delay(1000);
  Serial << _BYTE(27) << _BYTE(91) << _BYTE(50) << _BYTE(74); //CLR
  Serial << "\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t" << _DEC(12) << endl;
  delay(1000);
  Serial << _BYTE(27) << _BYTE(91) << _BYTE(50) << _BYTE(74); //CLR
  Serial << "\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t" << _DEC(13) << endl;
  delay(1000);
  Serial << _BYTE(27) << _BYTE(91) << _BYTE(50) << _BYTE(74); //CLR
  Serial << "\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t" << _DEC(14) << endl;
  delay(1000);
  Serial << _BYTE(27) << _BYTE(91) << _BYTE(50) << _BYTE(74); //CLR
  Serial << "\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t" << _DEC(15) << endl;
  delay(1000);
  Serial << _BYTE(27) << _BYTE(91) << _BYTE(50) << _BYTE(74); //CLR
  Serial << "\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t" << _DEC(16) << endl;
  delay(1000);
  Serial << _BYTE(27) << _BYTE(91) << _BYTE(50) << _BYTE(74); //CLR
  Serial << "\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t" << _DEC(17) << endl;
  delay(1000);
  Serial << _BYTE(27) << _BYTE(91) << _BYTE(50) << _BYTE(74); //CLR
  Serial << "\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t" << _DEC(18) << endl;
  delay(1000);
  Serial << _BYTE(27) << _BYTE(91) << _BYTE(50) << _BYTE(74); //CLR
  Serial << "\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t" << _DEC(19) << endl;
  delay(1000);
  Serial << _BYTE(27) << _BYTE(91) << _BYTE(50) << _BYTE(74); //CLR
  Serial << "\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t" << _DEC(20) << endl;
  delay(1000);
  while(1){} //freeze the main loop
}

Then putting each repeated line in a for loop, and adding a Maximum Count const variable, gives:
#include <Streaming.h>

const int MaxCount = 20;

//setup
void setup() {
 Serial.begin(9600);  //The faster the better
}   //Close the setup

//main loop
void loop() {
  for (int n = 1; n < 20; n++) {
    Serial << _BYTE(27) << _BYTE(91) << _BYTE(50) << _BYTE(74); //CLR
    Serial << "\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t" << _DEC(n) << endl;
    delay(1000);
  }

  while(1){} //freeze the main loop
}

However, jwpat7's answer is much better, and Nick's answer is the shortest.

authors: Александр Балан