Hello.
I was getting the value of the pressure sensor using the following code in the serial port of visual studio with Arduino Uno and pressure sensor, but when I use Arduino R4 minimum or WiFi model of R4, I can't get the value. Do you know how to solve this problem? Thank you in advance.
Receivedst = serialPort1.ReadLine(); //program code
can you post the working and none working code (using code tags </>)?
also a schematic of the UNO R4 wiring
are you using Software serial?
which code?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace testttest
{
public partial class Form1 : Form
{
String Receivedst;//Ardから受け取ったセンサの値(文字)
double Received;//Ardから受け取ったセンサの値(数値)
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
int a = 0;
while(a < 1000)
{
Received = Convert.ToDouble(Receivedst);
Console.WriteLine(Received);
++a;
System.Threading.Thread.Sleep(1000);
}
}
private void serialPort1_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)//データを受信するたびに実行
{
Receivedst = serialPort1.ReadLine(); //Ardから値を受け取り
}
private void Form1_Load(object sender, EventArgs e)
{
serialPort1.Open();
}
}
}
Thank you for your reply.
Here is the code.
Here is the schematic.
When using Arduino R3 Uno, I get the value of the pressure sensor, and when using Arduino R4 WiFi, I cannot get the value of the pressure sensor.
The code you posted does not compile.
This is not a schematic, but a very low qiality drawing. Not all connections are shown, the pin numbers are not visible.
In the diagram, the sensor is connected to the Arduino with one wire. Does this mean that you have not connected the ground of the sensor and the arduino?
And about the code - please show your arduino code too.
Sorry for the late reply.
Here is the schematic and the Arduino program.
void setup()
{
}
void loop()
{
int val = analogRead(A5);
Serial.print(val);
Serial.print("\n");
}
else
{
//digitalWrite(Trigger, LOW);
}
}
compile that
In the serial monitor
The compile is done and the pressure sensor value appears in both cases, but in visual studio with Arduino Uno, the value appears as above, but with Arduino R4 minima, the pressure sensor value is 0. How can I solve this problem?
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.