I am trying to use the 74HC595 shift register that I got with an Arduino kit in a project for my Raspberry Pi; however, the code that came with the Arduino kit does not make it clear how this would be done, as many of the functions called do not exist in C outside of the ArduinoIDE. The code provided is this:
//www.elegoo.com
//2016.12.9
int tDelay = 100;
int latchPin = 11; // (11) ST_CP [RCK] on 74HC595
int clockPin = 9; // (9) SH_CP [SCK] on 74HC595
int dataPin = 12; // (12) DS [S1] on 74HC595
byte leds = 0;
void updateShiftRegister()
{
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, LSBFIRST, leds);
digitalWrite(latchPin, HIGH);
}
void setup()
{
pinMode(latchPin, OUTPUT);
pinMode(dataPin, OUTPUT);
pinMode(clockPin, OUTPUT);
}
void loop()
{
leds = 0;
updateShiftRegister();
delay(tDelay);
for (int i = 0; i < 8; i++)
{
bitSet(leds, i);
updateShiftRegister();
delay(tDelay);
}
}
The Arduino seems to have libraries the following, while C itself does not:
Is there a way to incorporate libraries designed for the Arduino in a C package? Would I have to write my own libraries for the devices to work?
Arduino and C do not share the same libraries. Arduino libraries are saved under your_sketchbook_folder/libraries, while C headers are elsewhere. These are also not compatible in that you cannot simply and copy and paste the folders from one to the other. Each dependency has dependencies of its own, and moving the folders in this way leads to more errors.