#基层动态#【静海区局扎实提升计量服务水平 助力区域高质量发展】结合区域优势产业发展需求,静海区局加快更新检测仪器,积极构建涵盖区域主导产业、优势产业的一体化、多元化、集约化、专业化检验检测体系,为区域经济发展提供技术支撑。先后购置了CONST4001温度自动检定系统、机械式温湿度表检定装置、万能工具显微镜、瑞士梅特勒天平、高精度电子天平等先进检定设备。新设备的引进和使用,对试验检测数据准确度、检测工作效率和服务质量的提升起到积极的助推作用。
//是風之谷蟲王的電子結構與編碼,聲效雙色燈效,充電裝置
///https://t.cn/AiE3OYj4
/////////LED////////////
const int ledR = 9;
const int ledB = 10;
//////////microphone///////
const int sensorPIN = A0;
const int sampleWindow = 50;
/////////Button///////
const int buttonPin = 2;
int x=1;
int buttonState = 0;
////////fade///////////
int brightness = 0;
int fadeAmount = 5;
void setup()
{
/////////LED////////////
pinMode(ledR, OUTPUT);
pinMode(ledB, OUTPUT);
//////////microphone///////
Serial.begin(9600);
//////Button////
pinMode(buttonPin, INPUT);
}
void loop()
{
/////////Button///
if (x>7) {
x=1;
}
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH) {
x=x+1;
delay(500);
}
//////////microphone///////
unsigned long startMillis= millis();
unsigned int signalMax = 0;
unsigned int signalMin = 1024;
unsigned int sample;
while (millis() - startMillis < sampleWindow)
{
sample = analogRead(sensorPIN);
if (sample < 1024)
{
if (sample > signalMax)
{
signalMax = sample;
}
else if (sample < signalMin)
{
signalMin = sample;
}
}
}
unsigned int peakToPeak = signalMax - signalMin;
double volts = (peakToPeak * 5.0) / 1024;
Serial.println(volts);
switch (x) {
case 1:
analogWrite (ledR,50*volts);
analogWrite (ledB,5);
break;
case 2:
analogWrite (ledB,50*volts);
analogWrite (ledR,5);
break;
case 3:
analogWrite (ledB,50*volts);
analogWrite(ledR, brightness);
brightness = brightness + fadeAmount;
if (brightness <= 0 || brightness >= 255) {
fadeAmount = -fadeAmount;
}
delay(30);
analogWrite (ledR,50*volts);
analogWrite(ledB, brightness);
brightness = brightness + fadeAmount;
if (brightness <= 0 || brightness >= 255) {
fadeAmount = -fadeAmount;
}
delay(30);
break;
case 4:
analogWrite (ledB,0);
analogWrite(ledR, brightness);
// change the brightness for next time through the loop:
brightness = brightness + fadeAmount;
// reverse the direction of the fading at the ends of the fade:
if (brightness <= 0 || brightness >= 255) {
fadeAmount = -fadeAmount;
}
// wait for 30 milliseconds to see the dimming effect
delay(30);
break;
case 5:
analogWrite (ledR,0);
analogWrite(ledB, brightness);
// change the brightness for next time through the loop:
brightness = brightness + fadeAmount;
// reverse the direction of the fading at the ends of the fade:
if (brightness <= 0 || brightness >= 255) {
fadeAmount = -fadeAmount;
}
// wait for 30 milliseconds to see the dimming effect
delay(30);
break;
case 6:
analogWrite (ledR,250);
analogWrite (ledB,0);
break;
case 7:
analogWrite (ledR,0);
analogWrite (ledB,250);
break;
}
}
///https://t.cn/AiE3OYj4
/////////LED////////////
const int ledR = 9;
const int ledB = 10;
//////////microphone///////
const int sensorPIN = A0;
const int sampleWindow = 50;
/////////Button///////
const int buttonPin = 2;
int x=1;
int buttonState = 0;
////////fade///////////
int brightness = 0;
int fadeAmount = 5;
void setup()
{
/////////LED////////////
pinMode(ledR, OUTPUT);
pinMode(ledB, OUTPUT);
//////////microphone///////
Serial.begin(9600);
//////Button////
pinMode(buttonPin, INPUT);
}
void loop()
{
/////////Button///
if (x>7) {
x=1;
}
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH) {
x=x+1;
delay(500);
}
//////////microphone///////
unsigned long startMillis= millis();
unsigned int signalMax = 0;
unsigned int signalMin = 1024;
unsigned int sample;
while (millis() - startMillis < sampleWindow)
{
sample = analogRead(sensorPIN);
if (sample < 1024)
{
if (sample > signalMax)
{
signalMax = sample;
}
else if (sample < signalMin)
{
signalMin = sample;
}
}
}
unsigned int peakToPeak = signalMax - signalMin;
double volts = (peakToPeak * 5.0) / 1024;
Serial.println(volts);
switch (x) {
case 1:
analogWrite (ledR,50*volts);
analogWrite (ledB,5);
break;
case 2:
analogWrite (ledB,50*volts);
analogWrite (ledR,5);
break;
case 3:
analogWrite (ledB,50*volts);
analogWrite(ledR, brightness);
brightness = brightness + fadeAmount;
if (brightness <= 0 || brightness >= 255) {
fadeAmount = -fadeAmount;
}
delay(30);
analogWrite (ledR,50*volts);
analogWrite(ledB, brightness);
brightness = brightness + fadeAmount;
if (brightness <= 0 || brightness >= 255) {
fadeAmount = -fadeAmount;
}
delay(30);
break;
case 4:
analogWrite (ledB,0);
analogWrite(ledR, brightness);
// change the brightness for next time through the loop:
brightness = brightness + fadeAmount;
// reverse the direction of the fading at the ends of the fade:
if (brightness <= 0 || brightness >= 255) {
fadeAmount = -fadeAmount;
}
// wait for 30 milliseconds to see the dimming effect
delay(30);
break;
case 5:
analogWrite (ledR,0);
analogWrite(ledB, brightness);
// change the brightness for next time through the loop:
brightness = brightness + fadeAmount;
// reverse the direction of the fading at the ends of the fade:
if (brightness <= 0 || brightness >= 255) {
fadeAmount = -fadeAmount;
}
// wait for 30 milliseconds to see the dimming effect
delay(30);
break;
case 6:
analogWrite (ledR,250);
analogWrite (ledB,0);
break;
case 7:
analogWrite (ledR,0);
analogWrite (ledB,250);
break;
}
}
9.12
打卡第35天
1,线程互斥锁
a.int pthread_mutex_init(pthread_mutex_t *restrict mutex,
const pthread_mutexattr_t *restrict attr);
互斥锁初始化函数
b.int pthread_mutex_destroy(pthread_mutex_t *mutex);
互斥锁销毁函数
c.int pthread_mutex_lock(pthread_mutex_t *mutex);
int pthread_mutex_trylock(pthread_mutex_t *mutex);
上锁函数
d.int pthread_mutex_unlock(pthread_mutex_t *mutex);
解锁函数
2,条件变量
a.int pthread_cond_init(pthread_cond_t *restrict cond,
const pthread_condattr_t *restrict attr);
条件变量初始化函数
b.int pthread_cond_destroy(pthread_cond_t *cond);
条件变量销毁函数
c.int pthread_cond_timedwait(pthread_cond_t *restrict cond,
pthread_mutex_t *restrict mutex,
const struct timespec *restrict abstime);
定时休眠函数
d. int pthread_cond_wait(pthread_cond_t *restrict cond,
pthread_mutex_t *restrict mutex);
休眠函数
e. int pthread_cond_signal(pthread_cond_t *cond);
单独唤醒函数
f.int pthread_cond_broadcast(pthread_cond_t *cond);
集体唤醒函数 https://t.cn/EhGn2gw
打卡第35天
1,线程互斥锁
a.int pthread_mutex_init(pthread_mutex_t *restrict mutex,
const pthread_mutexattr_t *restrict attr);
互斥锁初始化函数
b.int pthread_mutex_destroy(pthread_mutex_t *mutex);
互斥锁销毁函数
c.int pthread_mutex_lock(pthread_mutex_t *mutex);
int pthread_mutex_trylock(pthread_mutex_t *mutex);
上锁函数
d.int pthread_mutex_unlock(pthread_mutex_t *mutex);
解锁函数
2,条件变量
a.int pthread_cond_init(pthread_cond_t *restrict cond,
const pthread_condattr_t *restrict attr);
条件变量初始化函数
b.int pthread_cond_destroy(pthread_cond_t *cond);
条件变量销毁函数
c.int pthread_cond_timedwait(pthread_cond_t *restrict cond,
pthread_mutex_t *restrict mutex,
const struct timespec *restrict abstime);
定时休眠函数
d. int pthread_cond_wait(pthread_cond_t *restrict cond,
pthread_mutex_t *restrict mutex);
休眠函数
e. int pthread_cond_signal(pthread_cond_t *cond);
单独唤醒函数
f.int pthread_cond_broadcast(pthread_cond_t *cond);
集体唤醒函数 https://t.cn/EhGn2gw
✋热门推荐