There is anyway to check the mode of a pin ?
like digitalRead(somePin) returns high or low
so some function the returns input or output
Im using arduino mega 2560...
The Arduino library doesn't provide a function to read the mode of a pin. It is possible to read a mode however, and if you like you can review this documentation:Atmel-2549
Reading a pin state will involve you having to figure out a port and register to read your mode from. This isn't recommended because the pin and port configuration will likely change between versions of micro-controllers. If you try to do something invalid to your hardware through your program you could end up with a fried microchip.
It would probably be best to store the mode as a variable to check what mode the pin in question has been set to.
Related
I'm using AI-Thinker's ESP32-S board, and my use case requires all 3 UARTs present in the board.
But, from the pin diagram, I can see that the UART1 pins also work as pins for integrated flash.
Of course, I need internal flash to actually be able to use the controller, but can I use the UART pins at the same time? Is this possible?
to use those pins without any problem you can compile the code with the flash in "dio" mode which by default does not use those pins, the spi-hd pin is to hold the memory, then the spi-wp pin is write protect. they are only used in "qio" mode that uses all 4 pins for higher communication speed, you can see the diferences here flash modes
As you probably guessed this question is not about a programming language but about arduino.
I'm making a big project which includes a GSM SIM900A module but it draws too much power.
I've looked up the datasheet but I didn't understand a lot as it references a DTR pin, something my module doesn't have.
Can someone tell me how to put it to sleep mode?
Any help will be grately appreciated!
Thanks in advance!
The GSM standard AT command for the setting of modem's level of functionality is AT+CFUN.
According to SIM900 AT commands guide its syntax is
AT+CFUN=fun[,rst]
Where:
fun: is the power saving mode
rst: is the reset flag
There are several possible values of fun parameter that can be supported or not depending on the modem vendor.
In order to reduce power consumption, SIM900A offers two possibilities:
AT+CFUN=0, means that the device is in sleep mode, and the AT interface is not accessible. Usually it keeps its network paging activities and its registration status to the network (it's not really clear from SIM900 guide). The device is woken up as soon as a wake up event occurs (for example an incoming SMS). Test it on your device.
AT+CFUN=4, that disable both TX and RX RF circuits. The AT interface remains reachable.
Usually first solution results in a bigger reduction of power consumption, but I suggest trying both of them in your specific board in order to understand what is the better choice for you.
I am using ESP8266 (NODEMCU 3.0 or something) to make a quadcopter. Ive connected ardu pro mini to RC receiver so I am reading PPM values from it. Pro mini sends data with tx to ESP8266. ESP reads it with software serial with 115200 baudrate. I am communicating with MPU9255 (Waveshire) via I2C either.
My problem is that I cant fully controll my brushless motors. When I was using arduino instead of ESP8266, servo library was the best and reliable. But ESP's servo library is different, since its not AVR, and problems occurs. First of the servo library didnt want to work on most frequencies. I mean default is 50Hz (20000uS) and in this state ESC of motors did armed but unfortunatelly when changes was fast and short (1250-> 1370 -> 1250) it did miss that change like nothing happnd... This makes my D value in PID controller useless...
Sometimes on 100Hz freq all was working fine, but sometimes not...
When Ive started to use analogWrite only 500Hz was working fine, rest of freq didnt want to arm ESCs.
PS. I am using 3.3V to 5V converter for PPM/PWM pins so I am sure that the signal is fine for ESCs.
PS2. I dont have any osciloscope unfortunately.
The ESP82266 present on your module is a RF transceiver integrated circuit that can handle WiFi communication, both configured as a slave to a microcontroller such as the ones present on various Arduino boards, or as a standalone chip by having it's on-board Tensilica L106 32-bit processor programmed via an external SPI flash memory. If used as a slave, the communication between, for example, an Arduino an the ESP82266 can be done using different protocols such as SPI / SDIO or I2C / UART interfaces. Googling a comprehensive Tensilica L106 user guide on the internet doesn't seem an easy task, and it looks as if some people have already failed to find it. If you're seeking to add Wi-Fi capabilities to your quadcopter the solution I suggest is having the Arduino take control over the servos, motors, etc. and hand off messages via SPI to your ESP82266 module. If this isn't the answer you are looking for, please try to be clearer about it, maybe find someone to do as an English translator for you.
However, if this is what you're concerned about, and you would like to use the ESP82266 module as as standalone solution, please link its built-in processor datasheet and the relevant parts of the quadcopters code that might need debugging.
I have an Arduino Uno and I am using arduino 1.0.5 IDE. I followed he procedures for bootloading an atmega328P-PU on a breadboard.
I uploaded the ArduinoISP sketch first, made the connections(using the External Oscillator) and then wired it up. Then, I selected the programmer as Arduino as ISP, selected the board as Arduino duemilanove w/ Atmega328P. Then I selected the correct serial port and clicked Burn Bootloader.
I got the following errors:
avrdude.exe: stk500_program_enable(): protocol error, expect=0x14,
resp=0x50avrdude.exe: initialization failed, rc=-1 Double
check connections and try again, or use -F to override
this check.avrdude.exe: stk500_disable(): protocol error, expect=0x14,
resp=0x51
How to solve this issue? Also, can I upload the bootloader directly by using it on the Uno in place of the original chip. If so, how?
to my understanding the error you have indicates a bad reading from the chip. I experienced that with chips that were either dead or not properly connected, especially to power supply.
You may find more detailed information in th tutorial : https://www.arduino.cc/en/Tutorial/ArduinoISP
Especially those things :
Note for Arduino 1.0: you need to make one small change to the
ArduinoISP code. Find the line in the heartbeat() function that says
"delay(40);" and change it to "delay(20);".
Select the items in the
Tools > Board and Serial Port menus that correspond to the board you
are using as the programmer (not the board being programmed).
Instead of arduino built-in boot loader just go through below link and it will be great for uploading boot loader and verifying board status info
I am replying you this because same issue I got long back and it saved me.
One more thing for arduino boot loader: for atmega328 you need to put capacitor between reset and gnd( in case you missed)
For gammon bootloader you don't need it.
Be Innovative.
For reset line you might me using 100nf(thats what stated in documentation )...but sometimes it doesn't work...try something like 4.7uf, 22uf or 47uf or close values
I had a similar problem and the issue was that my programmer was a bit slow, I used the -B flag for avrdude to slow down the bitrate and it started working, I set the -B20 and works like a charm every time, but I use the USBTinyISP programmer, not the stk500 one, so this might not work for you.
In case someone stuck at this as I did and nothing like changing the cap value helped. Make sure you are using your USB-TTL adapter in a 5v mode (obviously for a 5v powered chip). I always used it in a 3.3v mode in order not to accidentally burn my 3.3v chips and it always worked. Until today, I was trying to flash my custom atmega8 board and everything worked with the ISP but I was having a hard time using the bootloader and after half a day searching and trying different stuff the 5v setting to the rescue.
I have recently purchased an AVR USB programmer from robokits.co.in, was trying to program atmeg8 using AVR studio4 and I get the following when I click on the program options:
a problem occurred when executing the command. make sure u are using
the correct programming method. current mode is ISP verify that the
device is placed in the correct socket, and that the ISP cable is
connected properly.check that the programming frequency specified in
the main page is well below 1/4th of the clock frequency of the
device.
I have tried all that I could think of, I have checked the connections and the freq is below 1/4th of the device.
But that doesn't solve this problem.
I have made the circuit for blinking LEDs program.
See the image for details
Double check that the jumpers on the programming board that you are using (if you are) are set correctly.
Well this is hardly the venue to trouble shoot different hardware issues.
So if you think there is an issue with the programmer, contact www.robokits.com.
I would start with contacting robokits.
Since you can't even enter the programming mode, you can ignore your source code.
You should be able to verify fuses/lock bits w/o programming any code into the Mega8.
To give you a head start before you contact robokits:
1. Verify the programmer is properly installed on your computer following robokits instructions.
2. Verify the +5Vdc on Pins 20 & 7 of the Mega8
3. Verify Pins 22 & 8 are grounded properly.
4. Verify that Pin 1 is pulled up to +5Vdc (when the programmer is not connected)
Pin 1 should be pulled down by the programmer when it attempts to connect to the Mega8
5. Double check all the connections between the programmer to your target. Since the programmer is a 10 pin IDC and the test circuit has an in-line style connector you must have an IDC cable that has been broken out, stripped and connected to the test circuit.
Is the Target "fresh"? i.e. Never been programmed? Regardless: have you tried more than one?
Do you have any power being applied to the ISP header (target) prior to connecting the programmer?
You may also want to verify there are no shorts on your Target pulling the ISP Supply down, see the pinout link below.
If your jumper settings are USB-HID and Slow SCK == open && ISP Supply == short then you shouldn't supply and power to the ISP connection from the target.
If you are not supplying and voltage to the ISP header, maybe you should try that. Remove the ISP Supply jumper and apply 5V from your target application's supply to the ISP interface:
AVR ISP Pinout
Pin 2 on the ISP interface should be +5Vdc in reference to Pin 10 (gnd)
When I got a similar message while programming other Atmel integrated circuits I enabled the "Use external reset" setting that exists in the GUI of AVR Studio 4 (was removed in 5 and returned in Atmel Studio 6).
I am not sure if that option exists or does anything with your programmer since I have never used it.