Created
May 30, 2017 05:05
-
-
Save HectorTorres/0092a81417034fa39fcf482e759f481a to your computer and use it in GitHub Desktop.
arduino adc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Public Class Form1 | |
Dim v As String 'creacion de una variable llamda "v" | |
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'visualizacion del form1. | |
sp_1.Open() 'abrir o activar puerto serial. | |
Me.Location = New Point(380, 150) 'loacalizacion del form1. | |
Me.Size = New Size(517, 350) 'tamaño del form1. | |
Me.BackColor = Color.White 'declaracion del color del form1. | |
Timer1.Enabled = True 'habilitacion del timer1. | |
TextBox1.BackColor = Color.Aqua 'asignacion de color a los texbox. | |
TextBox2.BackColor = Color.Aqua ' "" | |
TextBox3.BackColor = Color.Aqua ' "" | |
TextBox4.BackColor = Color.Aqua ' "" | |
TextBox5.BackColor = Color.Aqua ' "" | |
End Sub | |
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick | |
Timer1.Interval = 2 'frecuencia de los eventos transcurridos en milisegundos. | |
v = sp_1.ReadLine 'asignacion del valor de la variable. | |
Try | |
If v >= 1 And v < 204 Then 'condicion de la variable. | |
TextBox1.BackColor = Color.FromArgb(v * 1.25, 0, 0) 'declaracio del color del texbox. | |
TextBox2.BackColor = Color.FromArgb(0, 0, 0) ' "" | |
TextBox3.BackColor = Color.FromArgb(0, 0, 0) ' "" | |
TextBox4.BackColor = Color.FromArgb(0, 0, 0) ' "" | |
TextBox5.BackColor = Color.FromArgb(0, 0, 0) ' "" | |
End If 'fin de la condicion | |
If v >= 204.8 And v < 409.6 Then 'segunda condicion deacuerdo a conforme adquiere datos el puerto serial. | |
TextBox1.BackColor = Color.FromArgb(255, 0, 0) | |
TextBox2.BackColor = Color.FromArgb((v * 1.25) - 255, 0, 0) ' "" | |
TextBox3.BackColor = Color.FromArgb(0, 0, 0) ' "" | |
TextBox4.BackColor = Color.FromArgb(0, 0, 0) ' "" | |
TextBox5.BackColor = Color.FromArgb(0, 0, 0) ' "" | |
End If ' fin de la condicion. | |
If v >= 409.6 And v < 614.4 Then 'Tercera condicion deacuerdo a conforme adquiere datos el puerto serial. | |
TextBox1.BackColor = Color.FromArgb(255, 0, 0) 'declaracion de color del texbox. | |
TextBox2.BackColor = Color.FromArgb(255, 0, 0) ' "" | |
TextBox3.BackColor = Color.FromArgb((v * 1.25) - 513, 0, 0) ' "" | |
TextBox4.BackColor = Color.FromArgb(0, 0, 0) ' "" | |
TextBox5.BackColor = Color.FromArgb(0, 0, 0) ' "" | |
End If 'fin de la condicion | |
If v >= 614.4 And v < 819.2 Then 'Cuarta condicion deacuerdo a conforme adquiere datos el puerto serial. | |
TextBox1.BackColor = Color.FromArgb(255, 0, 0) 'declaracion de color del texbox. | |
TextBox2.BackColor = Color.FromArgb(255, 0, 0) ' "" | |
TextBox3.BackColor = Color.FromArgb(255, 0, 0) ' "" | |
TextBox4.BackColor = Color.FromArgb((v * 1.25) - 769, 0, 0) ' "" | |
TextBox5.BackColor = Color.FromArgb(0, 0, 0) ' "" | |
End If 'fin de la condicion | |
If v >= 816 And v < 1024 Then 'Quinta condicion deacuerdo a conforme adquiere datos el puerto serial. | |
TextBox1.BackColor = Color.FromArgb(255, 0, 0) 'declaracion de color del texbox. | |
TextBox2.BackColor = Color.FromArgb(255, 0, 0) ' "" | |
TextBox3.BackColor = Color.FromArgb(255, 0, 0) ' "" | |
TextBox4.BackColor = Color.FromArgb(255, 0, 0) ' "" | |
If v > 1004 Then ' condicion | |
TextBox5.BackColor = Color.FromArgb((v * 1.25) - 1024, 0, 0) 'declaracion de color del texbox. | |
Else | |
TextBox5.BackColor = Color.FromArgb((v * 1.25) - 1000, 0, 0) 'declaracion de color del texbox. | |
End If 'fin de la condicion | |
End If 'fin de la condicion | |
If v = 1024 Then 'inicio de la condicion | |
TextBox1.BackColor = Color.FromArgb(255, 0, 0) 'declaracion de color del texbox. | |
TextBox2.BackColor = Color.FromArgb(255, 0, 0) ' "" | |
TextBox3.BackColor = Color.FromArgb(255, 0, 0) ' "" | |
TextBox4.BackColor = Color.FromArgb(255, 0, 0) ' "" | |
TextBox5.BackColor = Color.FromArgb(255, 0, 0) ' "" | |
End If 'fin de la condicion | |
If v = 0 Then 'inicio de la condicion | |
TextBox1.BackColor = Color.FromArgb(0, 0, 0) 'declaracion de color del texbox. | |
TextBox2.BackColor = Color.FromArgb(0, 0, 0) ' "" | |
TextBox3.BackColor = Color.FromArgb(0, 0, 0) ' "" | |
TextBox4.BackColor = Color.FromArgb(0, 0, 0) ' "" | |
TextBox5.BackColor = Color.FromArgb(0, 0, 0) ' "" | |
End If 'fin de la condicion | |
Catch ex As InvalidCastException | |
End Class |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment