Skip to content

Commit d48defa

Browse files
committed
FADER
1 parent 61743fd commit d48defa

2 files changed

Lines changed: 56 additions & 1 deletion

File tree

examples/Unit/AMeter_ADS1115/AMeter_ADS1115.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* describe: Ameter_ADS1115. 电流计
1010
* date:2021/8/19
1111
*******************************************************************************
12-
Please connect to Port A,Measure current and display.
12+
Please connect to Port A,Measure current and display in the screen.
1313
请连接端口A,测量电流并显示到屏幕上
1414
Pay attention: EEPROM (0x51) has built-in calibration parameters when leaving the factory.
1515
Please do not write to the EEPROM, otherwise the calibration data will be overwritten and the measurement results will be inaccurate.

examples/Unit/FADER/FADER.ino

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
*******************************************************************************
3+
* Copyright (c) 2021 by M5Stack
4+
* Equipped with M5Core sample source code
5+
* 配套 M5Core 示例源代码
6+
* Visit the website for more information:https://docs.m5stack.com/cn/unit/fader
7+
* 获取更多资料请访问:https://docs.m5stack.com/en/unit/fader
8+
*
9+
* describe:UNIT FADER. 滑动电位器/推子
10+
* date:2021/8/20
11+
*******************************************************************************
12+
Connect UNIT FADER to port B and push the FADER slider to adjust the input value and light brightness
13+
将UNIT FADER连接到B端口, 推动FADER滑杆即可实现调整输入数值大小与灯光亮度
14+
*/
15+
16+
#include "M5Stack.h"
17+
#include "FastLED.h"
18+
19+
// How many leds in your strip?
20+
#define NUM_LEDS 14
21+
#define INPUT_PINS 36
22+
23+
#define DATA_PIN 26
24+
25+
// Define the array of leds
26+
CRGB leds[NUM_LEDS];
27+
28+
uint8_t beginHue = 0;
29+
uint8_t deltaHue = 30;
30+
uint8_t brightness = 100;
31+
uint16_t rawADC = 0;
32+
33+
void setup()
34+
{
35+
M5.begin();
36+
M5.Lcd.setTextDatum(MC_DATUM);
37+
M5.Lcd.drawString("FADER UNIT TEST", 160, 60, 4);
38+
FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
39+
delay(1000);
40+
pinMode(36, INPUT);
41+
fill_rainbow(leds, NUM_LEDS, beginHue, deltaHue);
42+
}
43+
44+
45+
void loop()
46+
{
47+
rawADC = analogRead(INPUT_PINS); //Read ADC value 读取ADC数值
48+
brightness = map(rawADC, 0, 4095, 0, 255); //The mapping ADC value is the brightness value range 映射ADC值为亮度值范围
49+
FastLED.setBrightness(brightness); //Adjust the brightness of the FADER LED 调整FADER LED灯亮度
50+
FastLED.show();
51+
Serial.printf("%d\r\n", rawADC);
52+
M5.Lcd.fillRect(0, 120, 320, 100, BLACK);
53+
M5.Lcd.drawString("value: "+String(rawADC), 160, 160, 4);
54+
delay(100);
55+
}

0 commit comments

Comments
 (0)