Click here to Skip to main content
15,906,816 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have raspberrypi 2 modlde. i need to make serial data from the pi module. this is my code

VB
#!/usr/bin/env python


           import time
           import serial


           ser = serial.Serial(

               port='/dev/ttyAMA0',
               baudrate = 9600,
               parity=serial.PARITY_NONE,
               stopbits=serial.STOPBITS_ONE,
               bytesize=serial.EIGHTBITS,
               timeout=1
           )
           counter=0


           while 1:
               ser.write('Write counter: %d \n'%(counter))
               time.sleep(1)
               counter += 1


this is the error msg

XML
Traceback (most recent call last):
  File "/home/pi/Desktop/serial.py", line 3, in <module>
    import serial
  File "/home/pi/Desktop/serial.py", line 6, in <module>
    ser=serial.Serial(
AttributeError: 'module' object has no attribute 'Serial'
>>>


what is the error.pls help me...
thank you
Posted

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900