本文整理汇总了C++中pinMode函数的典型用法代码示例。如果您正苦于以下问题:C++ pinMode函数的具体用法?C++ pinMode怎么用?C++ pinMode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pinMode函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: pinMode
void Smarty::setButtonPin(uint8_t pin) {
m_buttonPin = pin;
pinMode(pin, INPUT_PULLUP);
}
开发者ID:shfanfan,项目名称:Smarty,代码行数:4,代码来源:Smarty.cpp
示例2: pinMode
void *toneHandler(void *arg)
{
tone_thread_param *param;
param = (tone_thread_param*)arg;
int tPin = param->tonePin;
pinMode(tPin, OUTPUT_FAST);
long delayAmount;
long loopTime;
unsigned long time1;
unsigned long time2;
int currentThreadControlID = param->threadID; //when threadControl[tPin] is modified by another thread it will no longer be equal to currentThreadControlID which exits the loop below allowing it to die
if((param->frequency) > 0)
{
delayAmount = (long)(1000000/(param->frequency))/2 - 1;
loopTime = (long)((param->duration*1000)/(delayAmount*2));
if((param->duration) > 0)
{
//implementing this way because delayMicroseconds is blocking which makes the generated tone not accurate enough
for (int x=0;x<loopTime;x++)
{
if(currentThreadControlID != threadControl[tPin])
{
break;
}
time1 = micros();
time2 = time1;
fastDigitalWrite(tPin,HIGH);
while(((long)(time2 - time1)) <= delayAmount)
{
time2 = micros();
}
time1 = micros();
fastDigitalWrite(tPin,LOW);
while(((long)(time2 - time1)) <= delayAmount)
{
time2 = micros();
}
}
}
else
{
//infinite loop
while(true)
{
if(currentThreadControlID != threadControl[tPin])
{
break;
}
time1 = micros();
time2 = time1;
fastDigitalWrite(tPin,HIGH);
while(((long)(time2 - time1)) <= delayAmount)
{
time2 = micros();
}
time1 = micros();
fastDigitalWrite(tPin,LOW);
while(((long)(time2 - time1)) <= delayAmount)
{
time2 = micros();
}
}
}
}
else
{
time1 = micros();
time2 = time1;
delayAmount = (param->duration)*1000;
while(((long)(time2 - time1)) <= delayAmount)
{
time2 = micros();
if(currentThreadControlID != threadControl[tPin])
{
break;
}
}
}
}
开发者ID:00alis,项目名称:corelibs-edison,代码行数:82,代码来源:Tone.cpp
示例3: pinMode
void decodeurDCF1_c::begin(uint8_t pin)
{
_pin = pin & 127;
pinMode(_pin, INPUT);
}
开发者ID:EDMB,项目名称:Arduino,代码行数:5,代码来源:decodeurDCF1.cpp
示例4: A110x2500Gdo0Init
void A110x2500Gdo0Init()
{
pinMode (RF_GDO0, INPUT);
}
开发者ID:JuergenGe,项目名称:Energia,代码行数:4,代码来源:Platform.cpp
示例5: pinMode
/* Constructor. */
Thermistor::Thermistor(int pin, TemperatureUnits units)
{
m_Pin = pin;
pinMode(m_Pin, INPUT);
m_Units = units;
}
开发者ID:CADemons,项目名称:Incufridge,代码行数:7,代码来源:thermistor.cpp
示例6: pinMode
//*****Sender Class Begins*****
Sender::Sender (short pinIn, Protocol * protIn){
pin = pinIn;
prot = protIn;
pinMode(pin,OUTPUT);
}
开发者ID:bhtp,项目名称:IRControlArduino,代码行数:6,代码来源:IR.cpp
示例7: Plugin_006
boolean Plugin_006(byte function, struct NodoEventStruct *event, char *string)
{
boolean success=false;
switch(function)
{
#ifdef PLUGIN_006_CORE
case PLUGIN_COMMAND:
{
DHT_Pin=PIN_WIRED_OUT_1+event->Par1-1;
byte dht_dat[5];
byte dht_in;
byte i;
byte Retry=0;
UserVariablePayload(event->Par2, 0x0011); // Temperature
UserVariablePayload(event->Par2+1,0x00d1); // Relative humidity %
do
{
pinMode(DHT_Pin,OUTPUT); // DHT start condition, pull-down i/o pin for 18ms
digitalWrite(DHT_Pin,LOW); // Pull low
delay(18);
digitalWrite(DHT_Pin,HIGH); // Pull high
delayMicroseconds(40);
pinMode(DHT_Pin,INPUT); // change pin to input
delayMicroseconds(40);
dht_in = digitalRead(DHT_Pin);
if(!dht_in)
{
delayMicroseconds(80);
dht_in = digitalRead(DHT_Pin);
if(dht_in)
{
delayMicroseconds(40); // now ready for data reception
for (i=0; i<5; i++)
dht_dat[i] = read_dht_dat();
byte dht_check_sum = dht_dat[0]+dht_dat[1]+dht_dat[2]+dht_dat[3]; // check checksum. Checksum calculation is a Rollover Checksum by design.
if(dht_dat[4]== dht_check_sum)
{
#if PLUGIN_006_CORE==11 // Code door de DHT-11 variant
TempFloat=float(dht_dat[2]); // Temperatuur
UserVariableSet(event->Par2 ,TempFloat,DHT_EVENT);
TempFloat=float(dht_dat[0]); // Vochtigheid
UserVariableSet(event->Par2+1,TempFloat,DHT_EVENT);
#endif
#if PLUGIN_006_CORE==22 || PLUGIN_006_CORE==33 // Code door de DHT-22 of DHT-33 variant
if (dht_dat[2] & 0x80) // negative temperature
{
TempFloat=-0.1 * word(dht_dat[2] & 0x7F, dht_dat[3]);
UserVariableSet(event->Par2,TempFloat,DHT_EVENT);
}
else
{
TempFloat=0.1 * word(dht_dat[2], dht_dat[3]);
UserVariableSet(event->Par2,TempFloat,DHT_EVENT);
}
TempFloat=word(dht_dat[0], dht_dat[1]) * 0.1; // vochtigheid
UserVariableSet(event->Par2+1,TempFloat,DHT_EVENT);
#endif
success=true;
}
}
}
if(!success)
delay(1000);
}while(!success && ++Retry<3);
break;
}
#endif // CORE
#if NODO_MEGA
case PLUGIN_MMI_IN:
{
char *TempStr=(char*)malloc(INPUT_COMMAND_SIZE);
if(GetArgv(string,TempStr,1))
{
if(strcasecmp(TempStr,PLUGIN_NAME)==0)
{
if(event->Par1>0 && event->Par1<HARDWARE_WIRED_OUT_PORTS && event->Par2>0 && event->Par2<=USER_VARIABLES_MAX_NR-1)
{
event->Type = NODO_TYPE_PLUGIN_COMMAND;
event->Command = PLUGIN_ID; // Plugin nummer
success=true;
}
}
}
free(TempStr);
//.........这里部分代码省略.........
开发者ID:stuntteam,项目名称:Nodo-Core,代码行数:101,代码来源:Plugin_006.c
示例8: servoTurn
/*****************************************************************************************************************************
*
* Send command to Servo to make turn it an turn back
*
* Returns:
* - RESULT_IS_OK
*
*****************************************************************************************************************************/
int8_t servoTurn(const uint8_t _servoPin, const uint16_t _targetPulseWidth, const uint32_t _turnTime, const uint32_t _holdTime = 0, const uint16_t _returnPulseWidth = 0)
{
uint32_t startHolding, idleTime, turnTime;
uint8_t servoPinPort, servoPinBit;
volatile uint8_t *servoOutRegister;
int8_t rc = RESULT_IS_FAIL;
servoPinBit = digitalPinToBitMask(_servoPin);
servoPinPort = digitalPinToPort(_servoPin);
if (NOT_A_PIN == servoPinPort) {
goto finish;
}
servoOutRegister = portOutputRegister(servoPinPort);
pinMode(_servoPin, OUTPUT);
stopTimerOne();
if (_targetPulseWidth) {
// if target angle (thru _targetPulseWidth) is specified - servo must get pulses every PULSE_INTERVAL (usually 20) ms
// for _turnTime and _holdTime to stay on position
//
// Work cycle = pulse_width_in_uS + (20 ms - pulse_width_in_ms)
idleTime = SERVO_PULSE_INTERVAL - (_targetPulseWidth / 1000UL);
turnTime = _turnTime + _holdTime;
startHolding = millis();
// Send pulse to turn the servo and hold it on position
do {
// Turn to the "target" angle
// ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
*servoOutRegister |= servoPinBit;
delayMicroseconds(_targetPulseWidth);
*servoOutRegister &= ~servoPinBit;
// }
// delay() is used because delayMicroseconds take no more that 16000 uS
delay(idleTime);
} while (turnTime > millis() - startHolding);
}
if (_returnPulseWidth) {
// if return angle (thru _returnPulseWidth) is specified - servo must get pulses every PULSE_INTERVAL (usually 20) ms
// for _turnTime
//
idleTime = SERVO_PULSE_INTERVAL - (_returnPulseWidth / 1000UL);
startHolding = millis();
do {
// Turn to the "return" angle
// ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
*servoOutRegister |= servoPinBit;
delayMicroseconds(_returnPulseWidth);
*servoOutRegister &= ~servoPinBit;
// }
// delay() is used because delayMicroseconds take no more that 16000 uS
delay(idleTime);
} while (_turnTime > millis() - startHolding);
}
startTimerOne();
rc = RESULT_IS_OK;
finish:
gatherSystemMetrics();
return rc;
}
开发者ID:zbx-sadman,项目名称:Zabbuino,代码行数:75,代码来源:actuators.cpp
示例9: pinMode
/**
* Enable transmissions
*
* @param nTransmitterPin Arduino Pin to which the sender is connected to
*/
void RCSwitch::enableTransmit(int nTransmitterPin) {
this->nTransmitterPin = nTransmitterPin;
pinMode(this->nTransmitterPin, OUTPUT);
}
开发者ID:nilclass,项目名称:coffeeclock,代码行数:9,代码来源:RCSwitch.cpp
示例10: pinModeNonDue
void Platform::Init()
{
byte i;
compatibility = me;
line->Init();
messageIndent = 0;
//network->Init();
massStorage->Init();
for(i=0; i < MAX_FILES; i++)
files[i]->Init();
fileStructureInitialised = true;
mcp.begin();
sysDir = SYS_DIR;
configFile = CONFIG_FILE;
ipAddress = IP_ADDRESS;
netMask = NET_MASK;
gateWay = GATE_WAY;
// DRIVES
stepPins = STEP_PINS;
directionPins = DIRECTION_PINS;
enablePins = ENABLE_PINS;
disableDrives = DISABLE_DRIVES;
lowStopPins = LOW_STOP_PINS;
highStopPins = HIGH_STOP_PINS;
maxFeedrates = MAX_FEEDRATES;
accelerations = ACCELERATIONS;
driveStepsPerUnit = DRIVE_STEPS_PER_UNIT;
instantDvs = INSTANT_DVS;
potWipes = POT_WIPES;
senseResistor = SENSE_RESISTOR;
maxStepperDigipotVoltage = MAX_STEPPER_DIGIPOT_VOLTAGE;
zProbePin = -1; // Default is to use the switch
zProbeCount = 0;
zProbeSum = 0;
zProbeValue = 0;
zProbeADValue = Z_PROBE_AD_VALUE;
zProbeStopHeight = Z_PROBE_STOP_HEIGHT;
// AXES
axisLengths = AXIS_LENGTHS;
homeFeedrates = HOME_FEEDRATES;
headOffsets = HEAD_OFFSETS;
// HEATERS - Bed is assumed to be the first
tempSensePins = TEMP_SENSE_PINS;
heatOnPins = HEAT_ON_PINS;
thermistorBetas = THERMISTOR_BETAS;
thermistorSeriesRs = THERMISTOR_SERIES_RS;
thermistorInfRs = THERMISTOR_25_RS;
usePID = USE_PID;
pidKis = PID_KIS;
pidKds = PID_KDS;
pidKps = PID_KPS;
fullPidBand = FULL_PID_BAND;
pidMin = PID_MIN;
pidMax = PID_MAX;
dMix = D_MIX;
heatSampleTime = HEAT_SAMPLE_TIME;
standbyTemperatures = STANDBY_TEMPERATURES;
activeTemperatures = ACTIVE_TEMPERATURES;
coolingFanPin = COOLING_FAN_PIN;
turnHeatOn = HEAT_ON;
webDir = WEB_DIR;
gcodeDir = GCODE_DIR;
tempDir = TEMP_DIR;
for(i = 0; i < DRIVES; i++)
{
if(stepPins[i] >= 0)
{
if(i > Z_AXIS)
pinModeNonDue(stepPins[i], OUTPUT);
else
pinMode(stepPins[i], OUTPUT);
}
if(directionPins[i] >= 0)
{
if(i > Z_AXIS)
pinModeNonDue(directionPins[i], OUTPUT);
else
pinMode(directionPins[i], OUTPUT);
}
if(enablePins[i] >= 0)
{
if(i >= Z_AXIS)
//.........这里部分代码省略.........
开发者ID:JonSteward,项目名称:RepRapFirmware,代码行数:101,代码来源:Platform.cpp
示例11: pinMode
void AnalogSwitch::Init(){
if (AnalogPin >= 0 && AnalogPin <= 5)
pinMode(AnalogPin, INPUT); //receive switch signal
}
开发者ID:mloispro,项目名称:ArduinoLibraries,代码行数:4,代码来源:AnalogSwitch.cpp
示例12: micros
void MeteoTemp::doStep3()
{
int i, j = 0, counter = 0;
uint8_t laststate = HIGH;
data[0] = data[1] = data[2] = data[3] = data[4] = 0;
#ifdef DEBUG
unsigned long begin = micros();
#endif
noInterrupts();
digitalWrite(_pin, HIGH);
delayMicroseconds(40);
pinMode(_pin, INPUT);
// read in timings
for ( i=0; i< MAXTIMINGS; i++) {
counter = 0;
while (digitalRead(_pin) == laststate) {
counter++;
delayMicroseconds(1);
if (counter == 255) {
break;
}
}
laststate = digitalRead(_pin);
if (counter == 255) break;
// ignore first 3 transitions
if ((i >= 4) && (i%2 == 0)) {
// shove each bit into the storage bytes
data[j/8] <<= 1;
if (counter > _count)
data[j/8] |= 1;
j++;
}
}
interrupts();
bool isOk = (j >= 40) &&
(data[4] == ((data[0] + data[1] + data[2] + data[3]) & 0xFF));
hasData = isOk;
if (isOk) {
mainLogic.temperatureUpdated();
}
status.needUpdate();
#ifdef DEBUG
unsigned long duration = micros() - begin;
Serial.print(F("DHT="));
Serial.print(isOk);
Serial.print(F(" took:"));
Serial.println(duration);
Serial.print(lastTemperature());
Serial.print(F("° "));
Serial.print(lastHumidity());
Serial.println(F("%"));
#endif
prepareStep1(false);
}
开发者ID:pludov,项目名称:ArdFocuser,代码行数:62,代码来源:meteotemp.cpp
示例13: pinMode
void MeteoTemp::doStep2()
{
pinMode(_pin, OUTPUT);
digitalWrite(_pin, LOW);
prepareStep3();
}
开发者ID:pludov,项目名称:ArdFocuser,代码行数:6,代码来源:meteotemp.cpp
示例14: pinMode
void LED::setup()
{
pinMode(outPin, OUTPUT);
}
开发者ID:poohzrn,项目名称:sw5,代码行数:4,代码来源:DummyLed.cpp
示例15: pinMode
void Ultrasonic::init(){
pinMode(tPin, OUTPUT);
digitalWrite(tPin, 0);
pinMode(ePin, INPUT);
}
开发者ID:imoralesgt,项目名称:Ultrasonic,代码行数:5,代码来源:Ultrasonic.cpp
示例16: gps_setup
//
// Exported functions
//
void gps_setup() {
#ifdef GPS_ON_PIN
pinMode(GPS_ON_PIN, OUTPUT);
digitalWrite(GPS_ON_PIN,HIGH);
#endif
}
开发者ID:nachoplus,项目名称:naranjino,代码行数:9,代码来源:gps.cpp
示例17: pinMode
// enable/disable blinking of pin 13 on IR processing
void IRrecv::blink13(int blinkflag)
{
irparams.blinkflag = blinkflag;
if (blinkflag)
pinMode(BLINKLED, OUTPUT);
}
开发者ID:sstefanov,项目名称:Arduino-IRremote,代码行数:7,代码来源:IRremote.cpp
示例18: pinMode
IRsendBase::IRsendBase () {
pinMode(TIMER_PWM_PIN, OUTPUT);
digitalWrite(TIMER_PWM_PIN, LOW); // When not sending PWM, we want it low
}
开发者ID:AlfredSch,项目名称:Arduino,代码行数:4,代码来源:IRLib.cpp
示例19: setup
/*
This initialization is called by the Arduino framework.
*/
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
pinMode(LED_RGB_RED, OUTPUT);
pinMode(LED_RGB_GREEN, OUTPUT);
pinMode(LED_RGB_BLUE, OUTPUT);
pinMode(SR_CLOCK, OUTPUT);
pinMode(SR_LATCH, OUTPUT);
pinMode(SR_SERIAL, OUTPUT);
pinMode(US_DIST_TRIG, OUTPUT);
pinMode(PASSIVE_BUZZLER, OUTPUT);
pinMode(US_DIST_ECHO, INPUT);
pinMode(LIGHT_SENSORS, INPUT);
pinMode(HUMAN_DETECTOR, INPUT);
pinMode(THERMOMETER, INPUT);
pinMode(JOYSTICK_X, INPUT);
pinMode(JOYSTICK_Y, INPUT);
pinMode(JOYSTICK_BUTTON, INPUT_PULLUP);
// Reset all virtual pins
vpFlush();
// Activate serial port with the given boud rate
Serial.begin(9600);
custom_setup(); // Application specific initialization
}
开发者ID:AsserHic,项目名称:aaapc,代码行数:30,代码来源:AAaPC.cpp
示例20: analogWrite
void analogWrite(uint32_t ulPin, uint32_t ulValue) {
if (ulValue == 0)
{
digitalWrite(ulPin, LOW);
return;
}
if (ulValue == 255)
{
digitalWrite(ulPin, HIGH);
return;
}
if (Timer1_Compare_Unit_Occupied_by_Pin[0] == ulPin)
{
update_PWM_value(ulPin, ulValue, 0);
}
else if (Timer1_Compare_Unit_Occupied_by_Pin[1] == ulPin)
{
update_PWM_value(ulPin, ulValue, 1);
}
else if (Timer1_Compare_Unit_Occupied_by_Pin[2] == ulPin)
{
update_PWM_value(ulPin, ulValue, 2);
}
else if (Timer2_Compare_Unit_Occupied_by_Pin[0] == ulPin)
{
update_PWM_value(ulPin, ulValue, 3);
}
else
{
if ((Timer1_Compare_Unit_Occupied_by_Pin[0] == 255) && (Timer1_Compare_Unit_Occupied_by_Pin[1] == 255) && (Timer1_Compare_Unit_Occupied_by_Pin[2] == 255))
{
// Timer1 is not used: need to initialize it
// Configure ulPin as output
digitalWrite(ulPin, LOW);
pinMode(ulPin, OUTPUT);
if (ulValue > 0)
{
// Configure GPIOTE channel "gpiote_channel" to toggle the PWM pin state
// Note that we can only connect one GPIOTE task to an output pin
nrf_gpiote_task_config(0, ulPin, NRF_GPIOTE_POLARITY_TOGGLE, NRF_GPIOTE_INITIAL_VALUE_LOW);
}
GPIOTE_Channels_Occupied[ulPin] = 0;
NRF_TIMER1->TASKS_STOP = 1;
NRF_TIMER1->MODE = TIMER_MODE_MODE_Timer;
//NRF_TIMER1->PRESCALER = 6; // Source clock frequency is divided by 2^6 = 64
NRF_TIMER1->PRESCALER = 0; // Source clock frequency is divided by 2^6 = 64 /////////////////////////////////////////
//NRF_TIMER1->BITMODE = TIMER_BITMODE_BITMODE_08Bit;
NRF_TIMER1->BITMODE = TIMER_BITMODE_BITMODE_16Bit; ////////////////////////////
// Clears the timer, sets it to 0
NRF_TIMER1->TASKS_CLEAR = 1;
NRF_TIMER1->CC[0] = (2^PWM_RESOLUTION - 1);
NRF_TIMER1->CC[1] = (2^PWM_RESOLUTION - 1);
NRF_TIMER1->CC[2] = (2^PWM_RESOLUTION - 1);
NRF_TIMER1->CC[3] = 0;
NRF_TIMER1->EVENTS_COMPARE[0] = 0;
NRF_TIMER1->EVENTS_COMPARE[1] = 0;
NRF_TIMER1->EVENTS_COMPARE[2] = 0;
NRF_TIMER1->EVENTS_COMPARE[3] = 0;
// Interrupt setup
NRF_TIMER1->INTENSET = (TIMER_INTENSET_COMPARE3_Enabled << TIMER_INTENSET_COMPARE3_Pos);
attachInterrupt(TIMER1_IRQn, TIMER1_Interrupt);
// Start clock
NRF_TIMER1->TASKS_START = 1;
turn_On_PPI_to_GPIO_for_PWM(ulPin, 0, NRF_TIMER1, 0);
PWM_Channels_Value[0] = (2^PWM_RESOLUTION - 1) - mapResolution(ulValue, _writeResolution, PWM_RESOLUTION);
Timer1_Compare_Unit_Occupied_by_Pin[0] = ulPin;
Pin_Occupied_for_PWM[ulPin] = 1;
}
else
{
if (Timer1_Compare_Unit_Occupied_by_Pin[0] == 255)
{
// Configure ulPin as output
digitalWrite(ulPin, LOW);
pinMode(ulPin, OUTPUT);
if (ulValue > 0)
{
// Configure GPIOTE channel "gpiote_channel" to toggle the PWM pin state
// Note that we can only connect one GPIOTE task to an output pin
nrf_gpiote_task_config(0, ulPin, NRF_GPIOTE_POLARITY_TOGGLE, NRF_GPIOTE_INITIAL_VALUE_LOW);
}
GPIOTE_Channels_Occupied[ulPin] = 0;
turn_On_PPI_to_GPIO_for_PWM(ulPin, 0, NRF_TIMER1, 0);
PWM_Channels_Value[0] = (2^PWM_RESOLUTION - 1) - mapResolution(ulValue, _writeResolution, PWM_RESOLUTION);
Timer1_Compare_Unit_Occupied_by_Pin[0] = ulPin;
Pin_Occupied_for_PWM[ulPin] = 1;
NRF_TIMER1->EVENTS_COMPARE[0] = 0;
}
else if (Timer1_Compare_Unit_Occupied_by_Pin[1] == 255)
{
// Configure ulPin as output
//.........这里部分代码省略.........
开发者ID:d00616,项目名称:nRF51duino,代码行数:101,代码来源:wiring_analog.c
注:本文中的pinMode函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论