I have basically connected a speaker to Arduino uno board. I just need help with the code. I have used the TMRpcm library to make it easier. However, it seems to be giving me an error everytime. here is the code below.
include "SD.h"
define SD_ChipSelectPin 10
include "TMRpcm.h"
include "SPI.h"
TMRpcm audio;
void setup(){
audio.speakerPin = 9;
Serial.begin(9600);
if (!SD.begin(SD_ChipSelectPin)) {
Serial.println("SD fail");
return;
}
audio.setVolume(10);
audio.play("Spring_In_My_Step_-_Silent_Partner_Mp3Converter_ne.wav");
}
void loop()
{
}
any and all help is appreciated
thank you!
Related
I need to send hex data from esp32wroom to a relay module. The communication is via RS485. The RS485 module used in SN75H12VD.The Rx and Tx pins are 16 and 17 of esp32. The enable pin is connected to pin 4. I have made the enable pin HIGH. I tried to use hardwareserial. Used a serial terminal to check whether the data is being sent. But nothing is getting printed. I also tried Serial2. But no luck. Please find my code below. It would be great if someone could help me with this.
#include<Arduino.h>
#include <HardwareSerial.h>
#define RXD2 16
#define TXD2 17
#define enable_pin 4
HardwareSerial mySer(2);
void setup()
{
Serial.begin(115200);
Serial.println("hi");
mySer.begin(9600, SERIAL_8N1, RXD2, TXD2);
pinMode(RXD2, INPUT);
pinMode(TXD2, OUTPUT);
pinMode(enable_pin, OUTPUT);
delay(10);
digitalWrite(enable_pin, HIGH);
}
void loop()
{
if (!mySer)
{ // If the object did not initialize, then its configuration is invalid
Serial.println("Invalid pin configuration, check config");
while (1) { // Don't continue with invalid configuration
delay (1000);
}
}
else {
Serial.println("hello");
mySer.println("hey");
mySer.write(0x13);
mySer.write(0x01);
mySer.write(0x03);
mySer.write(0x40);
mySer.write(0x02);
mySer.write(0x01);
mySer.write(0x00);
mySer.write(0xC9);
mySer.write(0x80);
mySer.write(0x0A);
delay(2000);
mySer.write(0x13);
mySer.write(0x01);
mySer.write(0x03);
mySer.write(0x40);
mySer.write(0x02);
mySer.write(0x00);
mySer.write(0x00);
mySer.write(0xC8);
mySer.write(0x10);
mySer.write(0x0A);
delay(2000);`enter code here`
}
}
I'm trying to get the TI-CC1101 433 MHz Transceiver Module to work with my NodeMCU ESP8266 but I am not sure about the wiring.
Link to the data sheet: LINK
Heres is a link with picture:LINK
I only want to use this Transceiver as a receiver for now so that's my setup:
NodeMCU 3.3 Volt --> VIC of TI-CC110
GND --> GND
NodeMCU D4 (2 in Arduino IDE) --> SI pin of TI-CC110.
I tested the following code with another 433 MHz receiving unit and it worked.
It's the example code of the RC Link Library:
#include <RCSwitch.h>
RCSwitch mySwitch = RCSwitch();
void setup() {
Serial.begin(9600);
mySwitch.enableReceive(2); // Receiver on interrupt 0 => that is pin #2
}
void loop() {
if (mySwitch.available()) {
int value = mySwitch.getReceivedValue();
if (value == 0) {
Serial.print("Unknown encoding");
} else {
Serial.print("Received ");
Serial.print( mySwitch.getReceivedValue() );
Serial.print(" / ");
Serial.print( mySwitch.getReceivedBitlength() );
Serial.print("bit ");
Serial.print("Protocol: ");
Serial.println( mySwitch.getReceivedProtocol() );
}
mySwitch.resetAvailable();
}
}
I get nothing when I'm trying the new module wired the way described above.
Hello the rc switch library does not support the cc1101 module officially. but there is an external driver library which allows to use the cc1101 module with rcswitch. Currently the esp modules are not supported. an update for esp is in planning.
https://github.com/LSatan/RCSwitch-CC1101-Driver-Lib
import processing.serial.*;
String COM5;
Serial myPort;
String val;
void setup() {
String portName=COM5;
myPort= new Serial(this,portName,9600);
}
void draw() {
if(myPort.available()>0){
val=myPort.readStringUntil('\n');
}
println(val);
}
This is my code, I have copied from a website. when I try running it is showing
Error opening serial port null:null not permitted
I am badly in need of answer to go forward in my thermal imaging project.
You never give COM5 a value, so it's null. Then you pass that into the Serial() constructor. The Serial() constructor doesn't know what do do with a null value, so you get the error.
Please take a step back and read a tutorial on using the Serial library. The official documentation contains example code that uses the Serial() constructor correctly.
COM5 hasn't got a value as a String.
Try this in Processing:
import processing.serial.*;
Serial myPort;
String val;
void setup() {
myPort= new Serial(this, "COM5", 9600);
}
void draw() {
if (myPort.available()>0) {
val=myPort.readStringUntil('\n');
}
println(val);
}
Double check your Arduino appears as COM5 in Device Manager and you don't have Arduino's Serial Monitor open when you run the Processing sketch.
I am trying to post an object to my parse.com app from my arduino yun and it needs to post a new object every second. So far I have been able to post every 10 seconds but I cannot seem to get the arduino to post any faster than that. I tried looking into the parse library but don't see what would be slowing it down. I am using the parse library given in the guide at https://www.parse.com/docs/arduino/guide.
here is the code I have so far.
#include <Parse.h>
#include <Bridge.h>
#include <arduino.h>
ParseObjectCreate create;
void setup() {
Serial.begin(9600);
parseInit();
}
void loop() {
parseFunc(24); // just send 24 everytime for testing
}
void parseInit()
{
Bridge.begin();
while (!Serial); // wait for a serial connection
Parse.begin("**********", "***********"); //my parse keys
create.setClassName("Temperature");
}
void parseFunc(float tempC)
{
create.add("temperature", tempC);
ParseResponse response = create.send();
response.close();
}
You are probably being rate limited by Parse. The code executed in loop() is executed as quickly as the micro controller can execute it - which is very fast. As a result, you are trying to write to Parse many many more times than once a second. Try putting a call to delay() after parseFunc(24). Something like:
parseFunc(24);
delay(1000); //delay is in milliseconds
Let me know if it works!
In a project, we try to set up a communication network between three ATtinys, where the first must receive messages from the other two. Those other two tinys are connected to two different pins of the first tiny. The first tiny must then receive two strings from the other tinys, one from each, and send it to an Arduino. For the communication we used SoftwareSerial. We managed to receive and send the input from one tiny, but not from both of them, because we could not find a way to read the input from only one specific pin at a time.
This is the code we used:
#include <SoftwareSerial.h>
const int rx=4;
const int rx2=1;
const int tx=3;
const int tx2=3;
SoftwareSerial mySerial(rx,tx);
SoftwareSerial mySerial2(rx2,tx2);
void setup()
{
pinMode(rx,INPUT);
pinMode(rx2,INPUT);
pinMode(tx,OUTPUT);
mySerial.begin(9600);
mySerial2.begin(9600);
}
void loop()
{
mySerial.listen();
if (mySerial.isListening()) {
mySerial.println("Port One is listening!");
mySerial.println(mySerial.read());
}
else{
mySerial.println("Port One is not listening!");
}
mySerial2.listen();
if (mySerial2.isListening()) {
mySerial2.println("Port Two is listening!");
mySerial2.println(mySerial2.read());
}
else{
mySerial2.println("Port Two is not listening!");
}
delay(500);
}
The code above worked without the part after mySerial2.listen();. Maybe the listen-function of SoftwareSerial does not work on the tinys, but if that is the case, is there another way to listen to a specific input pin?
Or do you have any advice what to do?