E
exernon
Guest
Hello!
I`m planning to build a solar apparatus project. Basically It will help show how different factors (angle of irradiance, temperature) affect the output of a photovoltaic cell. It will have sensors such as voltage sensor, current sensor, light sensor, temperature sensor. Also i would like to install servomotors that will tilt the photovoltaic cell and the light to simulate the angle of irradiance factor.
I would like to be able to see the sensor values and control the servomotors in visual studio. I already saw a youtube video on how i can seperately display the sensor values while displaying them all at once in the arduino . It is in visual basic format. And i found a video on controlling servo motors but it is in c# format. I am currently a beginner in coding in visual studio and i don`t quite understand how to convert the codes from visual basic to c#.
Imports System.IO
Imports System.IO.Ports
Public Class Form1
Dim value1 As Integer
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
SerialPort1.Close()
SerialPort1.PortName = "com5"
SerialPort1.BaudRate = "9600"
SerialPort1.DataBits = 8
SerialPort1.Parity = Parity.None
SerialPort1.StopBits = StopBits.One
SerialPort1.Handshake = Handshake.None
SerialPort1.Encoding = System.Text.Encoding.Default
SerialPort1.Open()
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
Dim s As String
s = TextBox1.Text + "," + "," + "," + ""
Dim somestring() As String
' Split string based on comma
somestring = s.Split(New Char() {","c})
TextBox2.Text = somestring(0)
TextBox3.Text = somestring(1)
TextBox4.Text = somestring(2)
TextBox1.Text = ""
End Sub
Private Sub DataReceived(ByVal sender As Object, e As SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived
Try
Dim mydata As String = ""
mydata = SerialPort1.ReadExisting()
If TextBox1.InvokeRequired Then
TextBox1.Invoke(DirectCast(Sub() TextBox1.Text &= mydata, MethodInvoker))
Else
TextBox1.Text &= mydata
End If
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
End Class
(the code i sent is for the getting the sensor values from arduino to visual studio )
So i`m asking if anyone could help me with this please.
Thank you!
Continue reading...
I`m planning to build a solar apparatus project. Basically It will help show how different factors (angle of irradiance, temperature) affect the output of a photovoltaic cell. It will have sensors such as voltage sensor, current sensor, light sensor, temperature sensor. Also i would like to install servomotors that will tilt the photovoltaic cell and the light to simulate the angle of irradiance factor.
I would like to be able to see the sensor values and control the servomotors in visual studio. I already saw a youtube video on how i can seperately display the sensor values while displaying them all at once in the arduino . It is in visual basic format. And i found a video on controlling servo motors but it is in c# format. I am currently a beginner in coding in visual studio and i don`t quite understand how to convert the codes from visual basic to c#.
Imports System.IO
Imports System.IO.Ports
Public Class Form1
Dim value1 As Integer
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
SerialPort1.Close()
SerialPort1.PortName = "com5"
SerialPort1.BaudRate = "9600"
SerialPort1.DataBits = 8
SerialPort1.Parity = Parity.None
SerialPort1.StopBits = StopBits.One
SerialPort1.Handshake = Handshake.None
SerialPort1.Encoding = System.Text.Encoding.Default
SerialPort1.Open()
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
Dim s As String
s = TextBox1.Text + "," + "," + "," + ""
Dim somestring() As String
' Split string based on comma
somestring = s.Split(New Char() {","c})
TextBox2.Text = somestring(0)
TextBox3.Text = somestring(1)
TextBox4.Text = somestring(2)
TextBox1.Text = ""
End Sub
Private Sub DataReceived(ByVal sender As Object, e As SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived
Try
Dim mydata As String = ""
mydata = SerialPort1.ReadExisting()
If TextBox1.InvokeRequired Then
TextBox1.Invoke(DirectCast(Sub() TextBox1.Text &= mydata, MethodInvoker))
Else
TextBox1.Text &= mydata
End If
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
End Class
(the code i sent is for the getting the sensor values from arduino to visual studio )
So i`m asking if anyone could help me with this please.
Thank you!
Continue reading...