Basic Arduino Coding

Pins in Arduino

Arduino-UNO-Pins
Arduino UNO Pins

How To Used Digital I/O pins

DECLARE PIN ARE USED

int pinnumber = 2,3,4,5….13; //any one

pinMode(pinNumber, MODE); //define in void setup

MODE = INPUT is getting value From external like 0v  and 5v (0 and 1)in digital

MODE = OUTPUT is generated output to outside world connected with it like hardware Led Blub To glow using (HIGH,LOW)

MODE = INPUT_PULLUP Arduino has internal pull-up resistors (resistors that connect to power internally) that you can access. If you prefer to use these instead of external pull-up resistors, you can use the INPUT_PULLUP argument in pinMode()

  • pinMode(pinNumber, INPUT); //Input mode
  • pinMode(pinNumber, OUTPUT); //Output mode
  • pinMode(pinNumber, INPUT_PULLUP); //Output mode

INPUT

int  buttonval = digitalRead(pinNumber);

Arduino Button
Arduino Button Read The Push Button .

By using this circuit Arduino Accepted the Push Button  Val. In the Form of HIGH & LOW ( 1 , 0 ).

CODE

This Allow To Read Button Value And Show the Arduino Led  Glow when the Button is beeing Press.

OUTPUT

digitalWrite(pin, [HIGH, LOW]);

HIGH  digitalWrite(pin,HIGH);

LOW digitalWrite(pin,LOW);

LEDSketch
LEDSketch To Blink LED

CODE

This Code is generated Led to blink one by one Connected to hardware Led Bulb .
the Circuit help to make Connection.


How To Used Analog pins

DECLARE PIN ARE USED

Analog pins A0,A1,A2,A3,A4,A5. In Uno

int analogRead(pin)
analogReference([DEFAULT, INTERNAL, EXTERNAL]) //Not Use in Basic Programming

Usage 

int Val = analogRead(A4); OR int Val = analogRead(pin);

The Analog Values is voltage between 0 and 5 volts. ADC is Converted into integer values between 0 and 1023. Or Some Times 0 to 255.

By display these Values we Used Serial Communication Which define in Void Setup() by Serial.begin(Baudrate);

Baudrate (Standard baud rates include 110, 300, 600, 1200, 2400, 4800, 9600, 14400, 19200, 38400, 57600, 115200, 128000 and 256000 bits per second. To display the supported baud rates for the serial ports on your platform)

Recommended Baudrate is 9600,57600,115200. Maximum Used by GPS,Finger Print Also.

Reading a Potentiometer (analog input)
Reading a Potentiometer (analog input)

CODE


How To Used PWM pins

Analog Value (PWM wave) to a pin.a LED at varying brightnesses or drive a motor at various speeds. After a call to analogWrite()

PWM Out – pins 3 5 6 9 10 11 (For Uno)

analogWrite(pin, value)

pin: the pin to write to.

value: the duty cycle: between 0 (always off) and 255 (always on).

Led Brightness using Analog (potentiometer) Arduino
Led Brightness using Analog (potentiometer)

CODE

Other Topics Related

Basics Of Arduino Programing

Learn Arduino Faster

Arduino First Time Run

(Visited 254 times, 1 visits today)
Start Arduino Coding

Tagged on:                         

3 thoughts on “Start Arduino Coding

Leave a Reply

Your email address will not be published. Required fields are marked *