Skip to content

Latest commit

 

History

History
70 lines (62 loc) · 4.73 KB

README.md

File metadata and controls

70 lines (62 loc) · 4.73 KB

107-Arduino-AS504x

Arduino Library Badge Compile Examples Check Arduino Check keywords.txt General Formatting Checks Spell Check

Arduino library for interfacing with various Austria Micro Systems angle position sensors.

This library works for

Example

#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);
}

Hardware

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