Click here to Skip to main content
15,883,929 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
What we want to do is when the arduino will send a signal to the C# app that we are making and when the arduino sent the A signal, a notification popup should appear, if it did not send, the notification box will not appear.

What I have tried:

C#
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            serialPort1.Open();
        }

        private void serialPort1_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
        {

            if (serialPort1.Read("A")) ;
            { Notification.Enabled = true; }
            else
            { Notification.Enabled = false; }
        }

        private void Notification_Click(object sender, EventArgs e)
        {
            PopupNotifier popup = new PopupNotifier();
            popup.Image = Properties.Resources.info;
            popup.TitleText = "Alert";
            popup.ContentText = "Hey";
            popup.Popup();
        }
    }
}
Posted
Updated 26-Feb-18 16:45pm
v3

1 solution

C#
if (serialPort1.WriteLine("A")) ;
You are not reading from the serial port, you are writing to it.

Please have a look at SerialPort.Read Method[^] or SerialPort.ReadByte Method[^] or SerialPort.ReadChar Method[^].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900