Newbie

i have buy arduino mini . i want to pickup the word "NG" from serial communication and LED will ON . How to program the arduino that situation .

Thanks

What is your programming experience?

Have you searched the site for information?

Weedpharma

i'm new in programming .. just now starting of learn the arduino programming .

thanks

Then go through the examples in the Arduino IDE, that problem is coverd.

See: PhysicalPixel in the examples to given you some ideas.

i have buy arduino mini . i want to pickup the word "NG" from serial communication and LED will ON . How to program the arduino that situation .

Something similar.

// zoomkat 8-6-10 serial I/O string test
// type a string in serial monitor. then send or enter
// for IDE 0019 and later

int ledPin = 13;
String readString;

void setup() {
  Serial.begin(9600);
  pinMode(ledPin, OUTPUT); 
  Serial.println("serial on/off test 0021"); // so I can keep track
}

void loop() {

  while (Serial.available()) {
    delay(3);  
    char c = Serial.read();
    readString += c; 
  }

  if (readString.length() >0) {
    Serial.println(readString);

    if (readString == "on")     
    {
      digitalWrite(ledPin, HIGH);
      Serial.println("LED ON");
    }
    if (readString == "off")
    {
      digitalWrite(ledPin, LOW);
      Serial.println("LED OFF");
    }
    readString="";
  } 
}

Thanks for program code .
Thanks all

if i want put the switch for reset LED on and . how to modify program that ?

Hi,

if i want put the switch for reset LED on and . how to modify program that ?

You want to type NG to turn on the LED and then press a button to turn that LED off

so you can type NG again to turn on that LED?

If so, try this:

// zoomkat 8-6-10 serial I/O string test
// type a string in serial monitor. then send or enter
// for IDE 0019 and later

const byte buttonPin = 2;
const byte ledPin = 7;
String readString;
byte buttonState = 0;
void setup() {
  Serial.begin(9600);
  pinMode(ledPin, OUTPUT);

  // initialize the pushbutton pin as an input:
  pinMode(buttonPin, INPUT_PULLUP);

  Serial.println("serial on/off test 0021"); // so I can keep track
}
void loop() {

  while (Serial.available()) {
    delay(3);
    char c = Serial.read();
    readString += c;
  }

  if (readString.length() > 0) {
    Serial.println(readString);

    if (readString == "NG")
    {
      digitalWrite(ledPin, HIGH);
      Serial.println("LED ON");
    }
 readString = "";
  }
  buttonState = digitalRead(buttonPin);
  if (buttonState == LOW) {
    // turn LED OFF
    digitalWrite(ledPin, LOW);
  }

}

arduino pin 2 <----->one leg of your button ---- ----the other leg of your button <---->arduino ground

(no resistors needed)

Let him learn with the examples and the references. Then let him come with his attempt to do what he wants and then, help him on that code, explaining what's right, what's wrong, etc.

I agree with @Sacha22.

@mohdazizi, The examples in serial input basics should be useful.

Please read "How to use the Forum" and understand the value of a meaningful Title for your Thread.

It is also a good idea to read as many Forum Threads as you can so as to absorb useful information.

...R

Spoon feed and they learn little.

Weedpharma

if i want put the switch for reset LED on and . how to modify program that ?

The below code is for button servo control, but part probably used for the LED reset.

//zoomkat servo button test 12-29-2011
// Powering a servo from the arduino usually *DOES NOT WORK*.

#include <Servo.h>
int button1 = 4; //button pin, connect to ground to move servo
int press1 = 0;
int button2 = 5; //button pin, connect to ground to move servo
int press2 = 0;
Servo servo1;

void setup()
{
  pinMode(button1, INPUT);
  pinMode(button2, INPUT);
  servo1.attach(7);
  digitalWrite(4, HIGH); //enable pullups to make pin high
  digitalWrite(5, HIGH); //enable pullups to make pin high
}

void loop()
{
  press1 = digitalRead(button1);
  if (press1 == LOW)
  {
    servo1.write(170);
  }    
  
  press2 = digitalRead(button2);
  if (press2 == LOW)
  {
    servo1.write(10);
  }
}