Show Posts
|
|
Pages: 1 [2] 3
|
|
17
|
Using Arduino / Interfacing w/ Software on the Computer / cannot read the data from arduino to the c#
|
on: January 09, 2013, 07:53:59 am
|
here is my program is c# public bool Connect() { button1.Enabled = false;
try { SP1.Open(); } catch (Exception) { MessageBox.Show("Invalid Serial Port"); return false; }
if (SP1.IsOpen) { System.Threading.Thread.Sleep(500); string data = SP1.ReadExisting(); SP1.WriteLine(data); System.Threading.Thread.Sleep(500);
however i cannot receive the data from arduino through serial port into the c#..how the readexisting functions?does the writeline function enable the data to be write into the c#?sorry,im new in c# and arduino.hope all of u can help.
|
|
|
|
|
19
|
Using Arduino / Interfacing w/ Software on the Computer / problem using lock statement in c#
|
on: December 30, 2012, 09:49:18 am
|
//create serial data BeginInvoke((Action)(()=> { lock (measures) { for (int i = 0; i < measures.Count; i++) { if (measures.Count >= 0.0 && measures.Count<=0.5) { double x = myCurveOne.Points.Count; double y = measures[i]; myCurveOne.AddPoint(x, y); myCurveOne.Line.Color = Color.Green; } else if (measures.Count>0.5 &&measures.Count<=0.6) { double x = myCurveTwo.Points.Count; double y = measures[i]; myCurveTwo.AddPoint(x, y); myCurveTwo.Line.Color = Color.Yellow; } else if (measures.Count > 0.6 && measures.Count <=0.7) { double x = myCurveThree.Points.Count; double y = measures[i]; myCurveThree.AddPoint(x, y); myCurveThree.Line.Color = Color.Red; } else return; } can i use this multiple if-else statement inside the lock block statements.?
|
|
|
|
|
20
|
Using Arduino / Interfacing w/ Software on the Computer / problem using zedgraph in C#
|
on: December 15, 2012, 05:38:37 am
|
hye everyone,im using the zedgraph to show the real time of water level. the water level range is 0-4.the x axis is the time( every hour).here are the code. private void zedGraphControl1_Load(object sender, EventArgs e) { // pane use to draw the chart GraphPane mypane = new GraphPane(); //point pair list PointPairList listPointsOne = new PointPairList(); PointPairList listPointsTwo = new PointPairList(); //line item LineItem myCurveOne; //set the pane mypane = zedGraphControl1.GraphPane; //set the title mypane.Title.Text = "Flood Monitoring System\n"; mypane.Title.IsVisible = true; // show the visibility of the title
//set the X axis mypane.XAxis.Type = AxisType.DateAsOrdinal; mypane.XAxis.Scale.Format = "HH:mm:ss"; mypane.XAxis.Title.Text = "Time"; mypane.XAxis.MajorGrid.IsVisible = true; mypane.XAxis.MinorGrid.IsVisible = true; mypane.XAxis.Scale.MajorUnit = DateUnit.Minute; mypane.XAxis.Scale.MinorUnit = DateUnit.Minute; mypane.XAxis.Title.IsVisible = true; //show the visibility of x axis title. mypane.XAxis.Scale.Min = 0; mypane.XAxis.Scale.Max = 24; mypane.XAxis.Scale.MajorStep = 1; mypane.XAxis.MinorTic.Size = 1;
//set the Y axis mypane.YAxis.Type = AxisType.Linear; mypane.YAxis.Title.Text = "Water Level"; mypane.YAxis.Scale.Format = @"0.0"; mypane.YAxis.Title.IsVisible = true; mypane.YAxis.MajorGrid.IsVisible = true; mypane.YAxis.Scale.Min = 0; mypane.YAxis.Scale.Max = 4; mypane.YAxis.Scale.MajorStep = 1;
//create dummy data double[] y = {1,2,3,2,1,4,2,4 }; double[] x = {0,10,14,16,18,20,22,24};
//add curve to the pane myCurveOne = mypane.AddCurve("WaterLevel",x,y,Color.Red,SymbolType.Triangle);
myCurveOne.Line.Width = 1.0F; //function that makesure the graph updated automatically zedGraphControl1.AxisChange(); zedGraphControl1.Invalidate(); zedGraphControl1.Refresh(); } my problem is that no data is appeared on the graph as well as the axis title and the title of the graph..
|
|
|
|
|
25
|
Using Arduino / Programming Questions / code for receiving serial data from transmitter
|
on: December 10, 2012, 11:09:54 pm
|
hi everyone,im working on flood monitoring system.here my arduino code for receiving data serially..is it this code really work? im receiving the latitude and longitude data from the transmitter as well as the water level data..is there any changes that i have to make in order to get the code work?sorry, im very new with arduino board...tq for ur help... #include <SPI.h> #include <Mirf.h> #include <nRF24L01.h> #include <MirfHardwareSpiDriver.h> int rate; void setup(){ Serial.begin(9600); Mirf.spi = &MirfHardwareSpi; Mirf.init(); Mirf.setRADDR((byte *)"serv1"); Mirf.payload = sizeof(rate); Mirf.config(); } void loop(){ while(!Mirf.dataReady()){ } Mirf.getData((byte *) &rate); Serial.println(rate); delay(100); }
|
|
|
|
|
26
|
Using Arduino / Interfacing w/ Software on the Computer / problem on case in switch statement in C#
|
on: December 10, 2012, 11:01:19 pm
|
hi everyone...would like to seek ur help in solving my problem..i have a problem of getting the warning sign...in addition, there an error stated that " control cannot fall through from one case label into another..im using c# language with visual basic 2010 ultimate software.. im also want to put the sign in serial..which means..when the transmitter sends the value of the voltage; the sign will appears accordingly.should i put the for statement for serial data? tq switch (waterlevel) { case "SAFE": if (voltage >= 0.0 || voltage <= 0.50) { label_result.Text = " SAFE"; label_result.ForeColor = Color.Green; break; }
case "WARNING": if (voltage >= 0.50 || voltage <= 0.60) { label_result.Text = " WARNING"; label_result.ForeColor = Color.Yellow; break; }
case "DANGER": if (voltage >= 0.60 || voltage <= 0.70) { label_result.Text = " DANGER"; label_result.ForeColor = Color.Red; break; } default: label_result.Text = "invalid"; break;
}
|
|
|
|
|
30
|
Using Arduino / Interfacing w/ Software on the Computer / Re: problem with visualbasic 2010 coding
|
on: November 17, 2012, 12:35:06 am
|
tuxdino..PaulS..here is the full code Imports System.Text Imports System.IO.Ports Imports System.Threading Imports System.TimeZone Imports System.Math
Public Class Form1 Dim voltage As Integer Dim WithEvents longitude As SerialPort = New _ System.IO.Ports.SerialPort("COM23", 9600, Parity.None, 8, StopBits.One)
Delegate Sub ProcessDataDelegate(ByVal Longitude As String, ByVal Latitude As String) Private Sub SerialPort1_DataReceived(ByVal sender As Object, _ ByVal e As SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived Try Dim Longitude As Integer = SerialPort1.ReadLine() Dim Latitude As Integer = SerialPort1.ReadLine() Me.Invoke(New ProcessDataDelegate(AddressOf ProcessData), Longitude, Latitude) Catch ex As Exception MessageBox.Show(ex.ToString, " Unable to get the location") SerialPort1.Close() End Try End Sub Sub ProcessData(ByVal Longitude As String, ByVal Latitude As String) TextBox1.Text = Longitude TextBox2.Text = Latitude End Sub Private Sub Button1_Click(ByVal sender As Object, ByVal _e As EventArgs) Handles Button1.Click If Button1.Text = "Close" Then SerialPort1.Close() Button1.Text = "Open" Else If Not SerialPort1.IsOpen Then SerialPort1.Open() Button1.Text = " Close"
End If End If
End Sub Private Sub Form1_FormClosing(ByVal sender As Object, ByVal _e As FormClosingEventArgs ) Handles Me.FormClosing SerialPort1.Close()
End Sub Private Sub WebBrowser2_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser2.DocumentCompleted WebBrowser2.Navigate("maps.google.com/maps?q=") End Sub
Private Sub CheckedListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) If (voltage <= 0.5) Then MsgBox("Checked") Else MsgBox("Unchecked")
End If End Sub
Private Sub CheckedListBox1_SelectedIndexChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckedListBox1.SelectedIndexChanged If CheckedListBox1.GetItemCheckState(voltage <= 0.5) Then CheckedListBox1.Text = True CheckedListBox1.CheckOnClick = True Else If Not CheckedListBox1.CheckOnClick Then CheckedListBox1.Text = False
End If
End If
End Sub
Private Sub TextBox3_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox3.TextChanged If (voltage <= 0.5) Then CheckedListBox1.Text = True MsgBox(" safe") TextBox3.Show() End If If (voltage >= 0.5 And voltage <= 0.6) Then CheckedListBox2.Text = True MsgBox(" WARNING") TextBox3.Show() End If If (voltage <= 0.6 And voltage <= 0.7) Then CheckedListBox3.Text = True MsgBox("DANGER") TextBox3.Show() End If
End Sub
Private Sub SplitContainer2_Panel2_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles SplitContainer2.Panel2.Paint
End Sub
Private Sub SplitContainer1_Panel1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles SplitContainer1.Panel1.Paint End Sub
Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub CheckedListBox2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckedListBox2.SelectedIndexChanged If CheckedListBox2.GetItemCheckState(voltage >= 0.5 And voltage <= 0.6) Then CheckedListBox2.Text = True CheckedListBox2.CheckOnClick = True Else If Not CheckedListBox2.CheckOnClick Then CheckedListBox1.Text = False End If End If
End Sub
Private Sub CheckedListBox3_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckedListBox3.SelectedIndexChanged If CheckedListBox3.GetItemCheckState(voltage >= 0.6 And voltage <= 0.7) Then CheckedListBox2.Text = True CheckedListBox2.CheckOnClick = True Else If Not CheckedListBox2.CheckOnClick Then CheckedListBox1.Text = False End If End If End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Timer1.Enabled = True Timer1.Interval = 1 End Sub
Private Sub PictureBox1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
PictureBox1.GetContainerControl() If (voltage = 0.5) Then
End If
End Sub
Private Sub Label6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label6.TextChanged
Label6.Text = DateString
End Sub
Private Sub Label7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label7.TextChanged
Label7.Text = TimeOfDay End Sub
End Class
|
|
|
|
|