Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Oct 2008
    Posts
    48
    Thanks
    1
    Thanked 0 Times in 0 Posts

    C# issue with arduino serial data and circular progress bar

    Hi All
    I have been racking my brains with a circular progress bar, I have managed to display the data from the serial data feed using text, but cannot for the life of me get the progress bar to move.
    I think the progress bar can inly use integar do I have tried sending whole numbers through the serial port with no luck.

    The error I get:Error CS0029 Cannot implicitly convert type 'string' to 'int' WindowsFormsApp2

    I have tried simply converting the string to int but wiht no luck, perharps a fresh set of eyes will help:

    Code:
    using System;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Collections.Generic;
    using System.Windows.Forms;
    using System.IO.Ports;
    
    namespace testtemp
    {
        public partial class tempreaderform : Form
        {
            public tempreaderform()
            {
                InitializeComponent();
            }
    
            
            communicator comport = new communicator();
            Boolean portConnection = false;
            private void button1_Click(object sender, EventArgs e)
            {
                if(comport.connect(9600, "I'M ARDUINO", 4, 8, 16))
                {
                    labelconnection.Text = "Connection Successful - Connected to  "+comport.port;
                    portConnection = true;
                    tempreader.Start();
                }
                else
                {
                    labelconnection.Text = "Not connected . . . ";
                    portConnection = false;
                    tempreader.Stop();
                }
            }
    
            private void tempreader_Tick(object sender, EventArgs e)
            {
                labeltemp.Text =  comport.message(4, 8, 32)+ "C";
                circularProgressBar1.Text = labeltemp.Text;
                circularProgressBar1.Value = circularProgressBar1.Text;
            }
            
    
           
            
        }
    }
    Thanks in advance

    Antony

  2. #2
    New Coder
    Join Date
    Oct 2008
    Posts
    48
    Thanks
    1
    Thanked 0 Times in 0 Posts
    ps this is the code that is causing my issue:

    Code:
               labeltemp.Text =  comport.message(4, 8, 32)+ "C";
                circularProgressBar1.Text = labeltemp.Text;
                circularProgressBar1.Value = circularProgressBar1.Text;
    thanks

    Antony
    Last edited by tonyjms2005; Apr 15th, 2019 at 02:50 PM.

  3. #3
    New Coder
    Join Date
    Oct 2008
    Posts
    48
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Hi again

    Sorted I converted the float into an integer in the Arduino code and did this in C#:

    Code:
                int x = 0;
    
                Int32.TryParse(comport.message(4, 8, 32), out x);
    
                labeltemp.Text =  comport.message(4, 8, 32)+ "C";
                circularProgressBar1.Text = labeltemp.Text;
                circularProgressBar1.Value = x;
    Thanks

    Antony

  4. #4
    New to the CF scene
    Join Date
    Apr 2019
    Location
    Dhaka, Bangladesh
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I think problem of your code
    circularProgressBar1.Value = circularProgressBar1.Text


 

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •