hii guys,
I have this attributeError in my python script. when I start the .exe it will immediately close.
I am trying to get my Serial from my arduino in my python script. somebody knows how to solve this problem??
this is my arduino script:
#include <LiquidCrystal.h>
#include <Keypad.h>
const byte numRows= 4;
const byte numCols= 3;
LiquidCrystal lcd(8, 9, 7, 6, 5, 4);
char keymap[numRows][numCols]=
{
{'1','2','3'},
{'4','5','6'},
{'7','8','9'},
{'*','0','#'}
};
byte rowPins[numRows]= {13, 12, 11, 10};
byte colPins[numCols]= {3, 2, A1};
Keypad myKeypad= Keypad(makeKeymap(keymap), rowPins, colPins, numRows, numCols);
char key,action;
int count=0;
void setup(){
Serial.begin(9600);
lcd.begin(16, 2);
lcd.setCursor(0,0);
lcd.print("BOEKNUMMER:");
}
void loop(){
char key = myKeypad.getKey();
if (key){
lcd.print(key);
Serial.print(key);
}
if (key =='*'){
lcd.clear();
lcd.print("BOEKNUMMER:");
lcd.setCursor(0, 1);
Serial.write("ja");
}
if (key =='#'){
Serial.write("nee");
}
}
and this is my python script:
import webbrowser
import serial
from serial import serial
with serial.Serial('COM5', 9600) as ser:
b = ser.readline()
random = input ("Wilt U een boek opzoeken? Ja/Nee: ")
random2 = ("gewoon een random tekst")
print(b)
if random in ["*Ja", "*ja", "JA", "jA", "yes", "Yes"]:
boek_nmmr = input ("Geef hier Uw boek ID/ISBN nummer op: ")
print(b)
boek_id = int(boek_nmmr)
webbrowser.open('https://educatief.dedicon.nl/products/search?Zoeken='+ boek_nmmr)
random3 = input ("Wilt U stoppen met zoeken? Ja of Nee (toets een nummer in voor nee): ")
print(b)
if random3 in ["Ja", "ja", "JA", "jA", "yes", "Yes"]:
print("Oké, nog een fijne dag!")
break
else:
print("nog een fijne dag")