Hola a todos.!
Estoy queriendo hacer andar un "led" con pwm arduino uno y You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login.. algo anda mal no me sale, quisiera saber si alguin me puede dar una mano.!!!
codigo de You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login.
Código: cpp
codigo de arduino
Código: cpp
Muchas Gracias a todos de antemano, saludos
fede
Estoy queriendo hacer andar un "led" con pwm arduino uno y You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login.. algo anda mal no me sale, quisiera saber si alguin me puede dar una mano.!!!
codigo de You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login.
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
With SerialPort1
.PortName = "COM3"
.BaudRate = 9600
.DataBits = 8
.Parity = IO.Ports.Parity.None
.StopBits = IO.Ports.StopBits.One
.Handshake = IO.Ports.Handshake.None
End With
Try
SerialPort1.Open()
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
SerialPort1.Write("1")
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
SerialPort1.Write("0")
End Sub
Private Sub TrackBar1_Scroll(sender As Object, e As EventArgs) Handles TrackBar1.Scroll
Label2.Text = TrackBar1.Value
Dim xxx As Integer
xxx = TrackBar1.Value
SerialPort1.Write(xxx) 'Estas xxx van de 1 a 255 y las tiene que leer arduino
End Sub
End Class
codigo de arduino
int LedPin = 3;
int xxx;
void setup() {
pinMode(7,OUTPUT);
pinMode(3,OUTPUT);
Serial.begin(9600);
}
void loop() {
if (Serial.available()){
int led =(int)Serial.read() -48;
analogWrite(LedPin,xxx); / Aca tendria que recibir los valores de 1 a 255 y mover o prender de apoco un led...
switch (led){
case 1:
digitalWrite(7,HIGH);
break;
case 0:
digitalWrite(7,LOW);
break;
// case 2:
//digitalWrite(6,OUTPUT);
// break;
}
}
}
Muchas Gracias a todos de antemano, saludos
fede

