I want to run an audio emulator of the genesis fm sound chip inside arduino. I plan to run it on a rp2040 which has plenty of power to run it
This is the emulator code:
https://github.com/nukeykt/Nuked-OPN2/blob/master/ym3438.h
And this is how Im trying to instantiate it, but I have errors. Can you point me on how to run the emulator?
#include "ym3438.h"
int buff = 0;
ym3438_t myChip;
void setup() {
}
void loop() {
buff++;
//this should advance the emultor clock
OPN2_Clock(myChip, buff);
//this should generate the sound samples
OPN2_Generate(myChip, buff);
}
Thanks!!
When trying to compile I get:
Compilation error: cannot convert 'ym3438_t' to 'ym3438_t*' for argument '1' to 'void OPN2_Clock(ym3438_t*, Bit16s*)'
I have tried putting* like:
OPN2_Clock(myChip*, buff*);
But it does not work either. Honesty Im not sure how to instantiate it
Related
I am java developer and pi4j begginer. I am developing java app that can control servo (raspberry pi 4 model b)
the error:
Exception in thread "main" java.lang.NoClassDefFoundError: com/pi4j/wiringpi/Gpio
at me.Olex7iMatix.CatBotSoftware.Main.main(Main.java:9)
Caused by: java.lang.ClassNotFoundException: com.pi4j.wiringpi.Gpio
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
... 1 more
JRE system library: JavaSE-1.8
the code
package me.Olex7iMatix.CatBotSoftware;
import com.pi4j.wiringpi.Gpio;
public class Main {
public static void main(String[] args) {
Gpio.pwmWrite(2, 50);
}
}
Edit: I just read the erorr message properly, you may need to just install the package, Installation guide
You are missing quite a lot of lines to get a servo to work with an RPi/Java.
You firstly need to tell the Pi which GPIO pin you are using and the output mode of said pin
com.pi4j.wiringpi.Gpio.pinMode({ENTER YOUR GPIO PIN HERE}, com.pi4j.wiringpi.Gpio.PWM_OUTPUT);
You also need to set the PWM Mode
com.pi4j.wiringpi.Gpio.pwmSetMode(com.pi4j.wiringpi.Gpio.PWM_MODE_MS);
com.pi4j.wiringpi.Gpio.pwmSetClock(192);
And then set the PWM Range
com.pi4j.wiringpi.Gpio.pwmSetRange(2000); // this may differ for your servo
Then you can set a loop do set the servo
while (true) {
com.pi4j.wiringpi.Gpio.pwmWrite({YOUR GPIO PIN}, 50);
Thread.sleep(10) // make this thread wait for 10 milliseconds
}
I am trying to compile my code. If I compile it in Arduino IDE it works, but if I try it in Visual Studio 2019 it fails.
I am trying to use a struct as a parameter.
I have tried pointer and typedef, but get the same error
I can compile it in Arduino IDE, but the same code gets this error in VS 2019:
Compiling debug version of 'test' for 'ATmega2560 (Mega 2560) (Arduino Mega)'
test.ino: 7:17: error: variable or field 'myFunction' declared void
Error compiling project sources
Debug build failed for project 'test'
test.ino: 7:17: error: 'data' was not declared in this scope
test.ino:7: note suggested alternative atan
atan
struct data{
float data;
};
data data_struct;
void myFunction(data data_struct){
}
int main(){}
You did not provide a declaration for myFunction. That's done by the Arduino IDE behind the scenes.
Try:
struct data{
float data;
};
data data_struct;
void myFunction(data data_struct);
void myFunction(data data_struct){
}
int main(){}
I am sending data from Arduino UNO R3 to nodeMcu esp8266. In that case sometime data are send properly but at sometime data are are not send by arduino or not get by nodemcu esp8266.Also tx light not blinks after i upload the code to the Arduiono.
enter code here
Code Uploaded to Arduino:
#include <SoftwareSerial.h>
#include <ArduinoJson.h>
SoftwareSerial s(10,11);
SoftwareSerial h(10,11);
int i=0;
void setup() {
// put your setup code here, to run once:
s.begin(9600);
Serial.begin(9600);
}
int f1=0;
int f2=0;
String st="sy";
void loop() {
f1=f1+1;
f2=f2+2;
// put your main code here, to run repeatedly:
StaticJsonBuffer <1000> bf;
StaticJsonBuffer <1000> rec;
JsonObject& root=bf.createObject();
JsonObject& receives=rec.parseObject(h);
if (receives==JsonObject::invalid())
{
Serial.println("no data from nodemcu");
root["data3"]="no data from nide";
}
else
{
root["data3"] = receives["data3"];
//st = (const char*)receive["data3"];
}
root["data1"]=f1;
root["data2"]=f2;
//root["data3"]=st;
if(s.available()>0)
{
root.printTo(s);
Serial.println("send");
}
else
{
Serial.println("NOt Available");}
//i=i+1;
//s.write(i);
delay(1000);
}
In your code thera are two reasons I can spot on the first look:
1 Never use delay in server client applications. Delay stops proccessing and inhibts communication. For more details how to avoid look at the blinkwithoutdelay built in Example in the Arduino IDE.
2. You use ArduinoJSON: This lib is absolute overkill for 99% of the applications it is used for. Don't get me wrong - the lib offers fantastic features, but if not needed this can be regarded as bloat-ware.
I wrote my own simple JSON coding/decoding (~250 lines of code) for a performant application using an Arduino as "Signal generator" and the ESP8266/ESP32 as a webserver. Communication between Arduino and ESPis time critical and so far it works over a year without problems,
I'm facing problem with sending AT Commands using Arduino Uno. I've written a small program (link below) to set up a server. I need to send data to Atmega from my laptop using Wifi module ESP8266. Everything would be fine if the entire program would do at once at the moment I need to comment and uncomment (adding and removing double slashes) every line of AT code, because only one AT command executes in a single compilation.
It seems like the program gets stuck somewhere in the while-loop (even on the module, I can see that blue diode stops blinking). I think that I've done something wrong in code and I would appreciate any help.
#include <SoftwareSerial.h>
SoftwareSerial espmod(2, 3);
void commands(String cmd, int waittime);
void setup(void) {
Serial.begin(9600);
espmod.begin(9600);
while (!Serial) {;}
commands("AT+GMR\r\n", 1000);
commands("AT+RST\r\n", 500);
commands("AT+CWMODE=1\r\n", 500);
commands("AT+CWJAP=\"SSID\",\"PASS\"\r\n", 4000);
commands("AT+CIPMUX=1\r\n", 500);
commands("AT+CIPSERVER=1,333\r\n", 500);
commands("AT+CIFSR\r\n", 500);
}
void loop() { // run over and over
}
void commands(String cmd, int waittime) {
espmod.print(cmd);
delay(waittime);
while(espmod.available()) {
char val = espmod.read();
Serial.write(val);
}
}
Here's the screen:
Version:
AT Version: 0.21.0.0
SDK Version: 0.9.5
Connections:
ESP
VCC -- 3,3 V (external source)
GND -- GND -- Arduino GND
RX -- TX (Arduino pin 3)
TX -- RX (Arduino pin 2)
CH_PD -- 3,3 V
RST -- 3,3 V
EDIT:
I've been fighting with this for couple of days, still without solution, but today it worked finally, but only once (after reseting power supply it's still the same) ! I could've seen all commands doing on SerialMonitor, so there is everything fine with code and i guess there is something wrong with esp module. As far as i can get only one AT command sent and executed in a single compilation, is it possible that 0,5 A current i provide to the module is not enough? Can module be out of the memory ? Is there any way to see SoftwareSerial monitor (is there anything like that)?
There is an unnecessary loop in command function. Let the arduino handle the loop for you. Also it is better to try with different delay parameters, maybe you can decrease some. Here the code I offer :
void loop() {
while (espmod.available()){
String result = espmod.readStringUntil('\n');
Serial.println("AT result : " + result);
}
}
void commands(String cmd, int waittime) {
espmod.print(cmd);
delay(waittime);
}
I am quite rusty when it comes to Serial ports. I want to send an AT command to a GSM/ GPRS shield connected to my Arduino UNO. The AT command I want to pass in particular is the command to get a networks signal strength.
I am using the SIM900 and SoftwareSerial library to send the command as the GSM library does not compile correctly for me. Meaning I have to use the SoftwareSerial library.
I have this example code from the SIM900 library working that relies on reading inputs from the serial monitor to carry out commands but I need it to be automated and the command to be passed in hardcoded. In this example code, the place of interest is the simplehwread() method.
#include "SIM900.h"
#include <SoftwareSerial.h>
int numdata;
char inSerial[40];
int i=0;
void setup()
{
//Serial connection.
Serial.begin(9600);
Serial.println("GSM Shield testing.");
//Start configuration of shield with baudrate.
//For http uses is raccomanded to use 4800 or slower.
if (gsm.begin(9600))
Serial.println("\nstatus=READY");
else Serial.println("\nstatus=IDLE");
};
void loop()
{
//Read for new byte on serial hardware,
//and write them on NewSoftSerial.
serialhwread();
//Read for new byte on NewSoftSerial.
serialswread();
};
void serialhwread()
{
i=0;
if (Serial.available() > 0) {
while (Serial.available() > 0) {
inSerial[i]=(Serial.read());
delay(10);
i++;
}
inSerial[i]='\0';
if(!strcmp(inSerial,"/END")) {
Serial.println("_");
inSerial[0]=0x1a;
inSerial[1]='\0';
gsm.SimpleWriteln(inSerial);
}
//Send a saved AT command using serial port.
if(!strcmp(inSerial,"TEST")) {
Serial.println("SIGNAL QUALITY");
gsm.SimpleWriteln("AT+CSQ");
} else {
Serial.println(inSerial);
gsm.SimpleWriteln(inSerial);
}
inSerial[0]='\0';
}
}
void serialswread()
{
gsm.SimpleRead();
}
No matter how I modify this code, the command does not get passed in and response displayed while the method here does it but not the way I want it to be done. i.e Direct input. Could anyone assist here?
i have dealt with exactly this scenario at a company with a cellular radio on board. there are many status signals that come over and if not dealt with appropriately these status flags from the cell modem will be lost
you need to look at the data sheets associated with your cell modem and its protocol so you know what flags to watch for at the various steps taken along the way from configuration, to eventual connection to cellular service.
multi-threaded coding techniques must be followed as well.
keep in mind that the comm channel is not ideal and there WILL be failures. provided your coding techniques are sound and you follow protocol requirements, then it should work.
Ron
Boise, ID