Wednesday, 9 November 2016

Connect Arduino and Python

Hi All,

The steps are simple. Here I am connecting my IOT Device Arduino with Python

Connect Python and Arduino


At First Run Arduino and select COM3 as port
with LDR Program
------------------------------------------------------------------------------
const int ldr = 0;    //A0 assigned as LDR pin.
int value = 0;        //Store values from LDR.

void setup()
{
  Serial.begin(9600);   //Fix serial baud rate at 9600bps
}

void loop()
{
  value = analogRead(ldr);    //Read the analog values from LDR. or simply use value=999
  Serial.println(value);      //Print to serial monitor.
  delay(250);                 //Delay of 250 milliseconds (1/4th of a second).
}

------------------------------------------------------------------------------
Then in the Python
install serial first.
then type this command

------------------------------------------------------------------------------
import time;
ser = serial.Serial('COM3', 9600, timeout=0,parity=serial.PARITY_EVEN, rtscts=1)
while True:
s=ser.read();
print(s);
time.sleep(3);
------------------------------------------------------------------------------

2 comments:

  1. If you are interested to learn more about the most sophisticated players in the outsourced product development industry, I'd highly recommend checking out this list of the best product development companies .

    ReplyDelete
  2. Creating a strong resume can be challenging when you need to present your skills, experience, and achievements effectively. Many job seekers consider resume writing services in india to improve their professional profiles and make their applications more polished. Expert guidance can help organize information, highlight relevant strengths, and maintain a professional format. A well-written resume can make it easier for recruiters to understand your background and may improve your confidence when applying for suitable career opportunities.

    ReplyDelete