I recently started into C++ and Arduino Coding which makes a lot of fun! I have different boards for example an Arduino UNO R3, Arduino Mini and an Arduino compatible Teensy 3.2.
I'd like to make my program to automatically select specific pins. Over the EEPROM library (not sure if library is the right term, as I said im new to c++) I can get the EEPROM size of each board. Is there any way to get other datas as how many digital/analgs pins the board has which can be used as Input and Output pins?
The number of digital pins is defined in the NUM_DIGITAL_PINS macro.
The number of analog input pins is defined in the NUM_ANALOG_INPUTS macro.
The macros are located at(added by request of OP):
Uno: https://github.com/arduino/Arduino/blob/1.6.12/hardware/arduino/avr/variants/standard/pins_arduino.h#L28-L29
#define NUM_DIGITAL_PINS 20
#define NUM_ANALOG_INPUTS 6
Mini: https://github.com/arduino/Arduino/blob/1.6.12/hardware/arduino/avr/variants/standard/pins_arduino.h#L28
#define NUM_DIGITAL_PINS 20
and
https://github.com/arduino/Arduino/blob/1.6.12/hardware/arduino/avr/variants/eightanaloginputs/pins_arduino.h#L25
#include "../standard/pins_arduino.h"
#undef NUM_ANALOG_INPUTS
#define NUM_ANALOG_INPUTS 8
Teensy 3.x:
https://github.com/PaulStoffregen/cores/blob/1.31/teensy3/core_pins.h#L97-L127
#if defined(__MK20DX128__)
#define CORE_NUM_TOTAL_PINS 34
#define CORE_NUM_DIGITAL 34
#define CORE_NUM_INTERRUPT 34
#define CORE_NUM_ANALOG 14
#define CORE_NUM_PWM 10
#elif defined(__MK20DX256__)
#define CORE_NUM_TOTAL_PINS 34
#define CORE_NUM_DIGITAL 34
#define CORE_NUM_INTERRUPT 34
#define CORE_NUM_ANALOG 21
#define CORE_NUM_PWM 12
#elif defined(__MKL26Z64__)
#define CORE_NUM_TOTAL_PINS 27
#define CORE_NUM_DIGITAL 27
#define CORE_NUM_INTERRUPT 24 // really only 18, but 6 "holes"
#define CORE_NUM_ANALOG 13
#define CORE_NUM_PWM 10
#elif defined(__MK64FX512__)
#define CORE_NUM_TOTAL_PINS 64
#define CORE_NUM_DIGITAL 64
#define CORE_NUM_INTERRUPT 64
#define CORE_NUM_ANALOG 27
#define CORE_NUM_PWM 20
#elif defined(__MK66FX1M0__)
#define CORE_NUM_TOTAL_PINS 64
#define CORE_NUM_DIGITAL 64
#define CORE_NUM_INTERRUPT 64
#define CORE_NUM_ANALOG 25
#define CORE_NUM_PWM 22
#endif
and
https://github.com/PaulStoffregen/cores/blob/1.31/teensy3/pins_arduino.h#L157-L158
#define NUM_DIGITAL_PINS CORE_NUM_DIGITAL
#define NUM_ANALOG_INPUTS CORE_NUM_ANALOG
The will be found in similar locations for other boards. You just need to check the build.variant value set in boards.txt for that board and then go to the folder of the same name under the variants folder of the board's platform.
You might find some other useful things by looking through those variant files.
Related
I am trying to set Nreadings in the Oscilloscope header file in tinyos above 5,say I set it at 6. When I do this, I notice that transmissions cease that is the green led does not blink signalling no transmissions are happening and instead I notice the red LED toggling telling me that there is an error. I went into the tos/types directory and opened message.h ,here I changed message length and set it to 56 from 28 as follows:
ifndef __MESSAGE_H__
#define __MESSAGE_H__
#include "platform_message.h"
#ifndef TOSH_DATA_LENGTH
#define TOSH_DATA_LENGTH 56
#endif
#ifndef TOS_BCAST_ADDR
#define TOS_BCAST_ADDR 0xFFFF
#endif
typedef nx_struct message_t {
nx_uint8_t header[sizeof(message_header_t)];
nx_uint8_t data[TOSH_DATA_LENGTH];
nx_uint8_t footer[sizeof(message_footer_t)];
nx_uint8_t metadata[sizeof(message_metadata_t)];
} message_t;
After making the above change I downloaded the Oscilloscope application onto my mote,yet the problem persists,am I missing something? After making the change to message_t, do I need to do compile something before i download the code?
I read some mcp2515.h files online. There is one part about SPI instruction set, or SPI commands. For example:
#define MCP_CMD_WRITE 0x02
#define MCP_CMD_READ 0x03
#define MCP_CMD_BIT_MODIFY 0x05
#define MCP_CMD_LOAD_TX 0x40
#define MCP_CMD_RTS 0x80
#define MCP_CMD_READ_RX 0x90
#define MCP_CMD_READ_STATUS 0xA0
#define MCP_CMD_RX_STATUS 0xB0
#define MCP_CMD_RESET 0xC0
Those hex 0*xx values look not like address. Or they are microchip defined values?
They refer to SPI instruction sets. Look under table 12-1. The definitions you are asking about is the instruction format converted to hex.
http://ww1.microchip.com/downloads/en/DeviceDoc/21801G.pdf
I would prefer to use standard Arduino API's if they are available. I need a way to check if arduino.h is present. If it is not available (i.e. executing code on BeagleBone Black), then I can use my own functions.
#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
Taken from: http://www.arduino.cc/en/Main/ReleaseNotes [internals]
I am getting the following error when building OpenCL with the AMD-APP SDK on Ubuntu:
Compilation failed:
"/tmp/OCLDUTgN7.cl", line 8: catastrophic error: cannot open source file
"src//owOpenCLConstant.h"
#include "src//owOpenCLConstant.h"
The owOpenCLConstant header file in question contains the following:
#ifndef OW_OPENCL_CONSTANT_H
#define OW_OPENCL_CONSTANT_H
#define MAX_NEIGHBOR_COUNT 32
#define MAX_MEMBRANES_INCLUDING_SAME_PARTICLE 7
#define LIQUID_PARTICLE 1
#define ELASTIC_PARTICLE 2
#define BOUNDARY_PARTICLE 3
#define NO_PARTICLE_ID -1
#define NO_CELL_ID -1
#define NO_DISTANCE -1.0f
#define QUEUE_EACH_KERNEL 1
#define INTEL_OPENCL_DEBUG 0
#endif // #ifndef OW_OPENCL_CONSTANT_H
This works with the Intel OpenCL1.1 SDK so it seems a bit strange. Is it an AMD-specific problem or could it be an OpenCL1.1 vs 1.2 thing?
I don't know much about OpenCL and haven't been able to find this error anywhere, if anyone can spot the problem I would greatly appreciate it.
I am trying to drive a 6v dc motor with L293D driver and Atmega8 without PWM. The problem is i am getting very low speed while connecting the motor with L293D driver. But, it rotates well when i provide direct 6V dc supply to the motor. I am using external 6v source at V2(motor supply) pin of L293D, but no improvement. The motor does not rotate until i turn the rotor with hand. Is the problem remaining for not using PWM? My code is here:
DDRB = 0xFF;
while(1)
{
PORTB = 0B00000010;
_delay_ms(20000);
}
i think may be you forgot to make Enable 1 pin high, if your connections is like this than
PB0 --> IN1
Penter code hereenter code here`B1 --> IN2
PB3 --> EN1
and pin 8 of L293d will connected with External Battery.
than code like this :
DDRB = 0xFF;
while(1) {
PORTB = 0B00000110;
_delay_ms(20000);
}