Show Posts
Pages: 1 [2] 3
16  Using Arduino / Interfacing w/ Software on the Computer / Re: cannot read the data from arduino to the c# on: January 09, 2013, 08:12:43 am
i have initialized the serial port.
Code:
SP1 = new SerialPort("COM3" ,9600,Parity.None,8,StopBits.One);
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#
Code:
   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.
18  Using Arduino / Interfacing w/ Software on the Computer / Re: problem using lock statement in c# on: December 31, 2012, 09:45:29 am
robtillaart,

i am thinking like that..but for the value measure 0-5 im referring to the first if-else block statement.. n so on..does the code works on the condition that i have set on my original coding?

thanks...
19  Using Arduino / Interfacing w/ Software on the Computer / problem using lock statement in c# on: December 30, 2012, 09:49:18 am
Code:
  //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.
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..
21  Using Arduino / Programming Questions / Re: code for receiving serial data from transmitter on: December 12, 2012, 06:13:28 am
i got the code online...refering to the code...there are no initialization of pin...does it works?
22  Using Arduino / Interfacing w/ Software on the Computer / how to do the real-time line graph using c# command? on: December 12, 2012, 04:45:40 am
hye everyone...i want to draw the line graph that the data will change in real time using c# language in Visual studio 2010?any good links and guidelines?tq

p/s: the serial data im getting from arduino uno microcontroller.
23  Using Arduino / Interfacing w/ Software on the Computer / Re: problem on case in switch statement in C# on: December 11, 2012, 09:35:17 am
thanks Paul for the help..i have rectified the problem..
24  Using Arduino / Interfacing w/ Software on the Computer / Re: problem on case in switch statement in C# on: December 11, 2012, 07:15:53 am
ok.AWOL...im declaring the water level as string...can u help me to debug my code?tq

Paul: yeah..this is visual studio 2010 ultimate..sorry for the mistakes..
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...
Code:
#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

Code:
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;

                }
27  Using Arduino / Interfacing w/ Software on the Computer / Re: problem with visualbasic 2010 coding on: November 21, 2012, 02:24:47 am
i will send the code for u to help me debug it.tq.

" sorry for asking a lot of question above as im new in arduino and visual basic"
28  Using Arduino / Interfacing w/ Software on the Computer / Re: problem with visualbasic 2010 coding on: November 19, 2012, 03:53:56 am
ok.Pauls.how to attach the zip file here.thanks..
29  Using Arduino / Interfacing w/ Software on the Computer / Re: problem with visualbasic 2010 coding on: November 17, 2012, 11:16:50 pm
no.because of the error..i cannot compile the code.it gets hang eventhough there are no syntax error stated.maybe it wont works because im receiving the lat and long by a serial comm from the receiver.
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
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
Pages: 1 [2] 3