I write a program where arduino reads numbers from analogRead and temporarily stores them in a buffer, but it's not working well.Please let me know how I can solve this problem.
I am trying to use an array to resolve the above, but I cannot read the official numbers.
This is what we need to do to run the arduino program with python and display the numbers on python.
The current code is as follows:
Thank you for your cooperation.
void setup()
{
pinMode(1,OUTPUT);
Serial.begin (9600);
}
void loop()
{
chara;
if (Serial.available()>0)
{
a = Serial.read();
if(a=='z')
{
delay(10);
digitalWrite (8, LOW);
Measure();
}
if(a=='y')
{
digitalWrite (8, HIGH);
}
}
}
void Measure()
{
intx;
intv[300];
inti [300];
for (x=1; x<=300;x++)
{
v[x] = analogRead (A3);
i[x] = analogRead(A4);
delayMicroseconds (1000);
}
delay(5000);
for (x=1; x<=300;x++)
{
Serial.print(v[x]);
Serial.print(', ');
Serial.println(i[x]);
}
}
Is the input pin designation correct?
I can't find the code that defines the input pin used in the function Measure(), A3, A4 values.
v[x]=analogRead(A3);
i[x] = analogRead(A4);
If you want to read analog values from pins 3 and 4,
v[x]=analogRead(3);
i[x] = analogRead(4);
Try correcting it.
If "Unable to read official numbers" refers to a phenomenon in which fluctuating values are read without meaning, it is likely that analog values are read from empty pins.
So I suspected the analogRead argument.
613 GDB gets version error when attempting to debug with the Presense SDK (IDE)
916 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
578 Understanding How to Configure Google API Key
618 Uncaught (inpromise) Error on Electron: An object could not be cloned
© 2024 OneMinuteCode. All rights reserved.