Raspberry send data via serial USB to Arduino Python
<p>Hi I have connected my raspberry to arduino via serial USB and on arduino there is a led that I want turn on if in the script in python I send a letter o a number</p>

<p>I have write this code in raspberry Python:</p>

<pre><code>import serial
ser=serial.Serial('/dev/ttyUSB0', 9600)
ser.write('3')
</code></pre>

<p>In my arduino I have load this skatch:</p>

<pre><code>const int ledPin = 12;
int val;
void setup(){
  pinMode(ledPin, OUTPUT);
  Serial.begin(9600);
}

void loop(){
  if (Serial.available())  {
     val=Serial.read();
     if(vale==3)
       digitalWrite(ledpin, HIGH);
  }
  delay(500);
} 
}
</code></pre>

<p>When I lunch the script py from rasp, I see that led not turn on, but turn on a onboard led of arduino.</p>

<p>I think that the problem is the type of data like ASCII or integer but I don't understand how to fix. 
Serial device is ok and is USB0 and the pin of led on arduino is right
Please help me</p>

<p>There is a typo in the if statement, you have put vale instead of val.</p>

<pre><code>ser.write('3')
</code></pre>

<p>takes 3 as a string.So try this in the if statement,</p>

<pre><code>if(val=='3')
</code></pre>

python serialization arduino