Arduino library for interfacing with various Austria Micro Systems angle position sensors.
This library works for
- ArduinoCore-samd:
Arduino Zero
,MKR 1000
,MKR WiFi 1010
,Nano 33 IoT
,MKR GSM 1400
,MKR NB 1500
,MKR WAN 1300/1310
✔️ - ArduinoCore-mbed:
Portenta H7
,Nano 33 BLE
,Nano RP2040 Connect
,Edge Control
✔️ - arduino-esp32:
ESP32 Dev Module
,ESP32 Wrover Module
, ... ✔️ - arduino-pico:
Raspberry Pi Pico
,Adafruit Feather RP2040
, ... ✔️ - ArduinoCore-renesas:
Portenta C33
,Uno R4 WiFi
,Uno R4 Minima
, ... ✔️
#include <107-Arduino-AS504x.h>
/* ... */
static SPISettings const AS504x_SPI_SETTING{1000000, MSBFIRST, SPI_MODE1};
/* ... */
ArduinoAS504x angle_pos_sensor([](){ SPI.beginTransaction(AS504x_SPI_SETTING); },
[](){ SPI.endTransaction(); },
[](){ digitalWrite(AS504x_CS_PIN, LOW); },
[](){ digitalWrite(AS504x_CS_PIN, HIGH); },
[](uint8_t const d) -> uint8_t { return SPI.transfer(d); },
delayMicroseconds);
/* ... */
void setup()
{
SPI.begin();
pinMode(AS504x_CS_PIN, OUTPUT);
digitalWrite(AS504x_CS_PIN, HIGH);
}
void loop()
{
char msg[64] = {0};
snprintf(msg, sizeof(msg), "Angle (Raw) = %d", angle_pos_sensor.angle_raw());
Serial.println(msg);
delay(100);
}
Breakout/Development-Board
Colour | Nano RP2040 Pin | AS5048A-TS_EK_AB Pin |
---|---|---|
Red | 3.3V | 3.3V |
Black | GND | GND |
Green (1) | CIPO | MISO |
Yellow | COPI | MOSI |
Blue | SCK | SCK |
Green (2) | D2 | CSn |