dcexpert

个性签名:一起来玩 microbit/micropython

  • 2020-08-09
  • 加入了学习《KOL 4 欢迎进入MicroPython的奇妙世界》,观看 欢迎进入MicroPython的奇妙世界

  • 回复了主题帖: LED夏威夷四弦琴

    qwqwqw2088 发表于 2020-8-9 10:58 人不用拨弦了么 是配乐?
    演奏还得拨弦,但是LED可以配合旋律。

  • 2020-08-08
  • 回复了主题帖: LED夏威夷四弦琴

    参考代码(circuitpython):   """ LED Ukulele with Feather Sense and PropMaker Wing Adafruit invests time and resources providing this open source code. Please support Adafruit and open source hardware by purchasing products from Adafruit! Written by Erin St Blaine & Limor Fried for Adafruit Industries Copyright (c) 2019-2020 Adafruit Industries Licensed under the MIT license. All text above must be included in any redistribution. MODES: 0 = off/powerup, 1 = sound reactive, 2 = non-sound reactive, 3 = tilt Pluck high A on the E string to toggle sound reactive mode on or off Pluck high A♭ on the E string to cycle through the animation modes """ import time import array import digitalio import audiobusio import board import neopixel import ulab.numerical as numerical import ulab.extras as extras import ulab as np import adafruit_lsm6ds from adafruit_led_animation.helper import PixelMap from adafruit_led_animation.sequence import AnimationSequence from adafruit_led_animation.group import AnimationGroup from adafruit_led_animation.animation.sparkle import Sparkle from adafruit_led_animation.animation.rainbow import Rainbow from adafruit_led_animation.animation.rainbowchase import RainbowChase from adafruit_led_animation.animation.rainbowcomet import RainbowComet from adafruit_led_animation.animation.chase import Chase from adafruit_led_animation.animation.comet import Comet from adafruit_led_animation.color import colorwheel from adafruit_led_animation.color import ( BLACK, RED, ORANGE, BLUE, PURPLE, WHITE, ) MAX_BRIGHTNESS = 0.3 #set max brightness for sound reactive mode NORMAL_BRIGHTNESS = 0.1 #set brightness for non-reactive mode VOLUME_CALIBRATOR = 50 #multiplier for brightness mapping ROCKSTAR_TILT_THRESHOLD = 200 #shake threshold SOUND_THRESHOLD = 430000 #main strum or pluck threshold # Set to the length in seconds for the animations POWER_ON_DURATION = 1.3 ROCKSTAR_TILT_DURATION = 1 NUM_PIXELS = 104 # Number of pixels used in project NEOPIXEL_PIN = board.D5 POWER_PIN = board.D10 enable = digitalio.DigitalInOut(POWER_PIN) enable.direction = digitalio.Direction.OUTPUT enable.value = False i2c = board.I2C() pixels = neopixel.NeoPixel(NEOPIXEL_PIN, NUM_PIXELS, brightness=1, auto_write=False) pixels.fill(0) # NeoPixels off ASAP on startup pixels.show() #PIXEL MAPS: Used for reordering pixels so the animations can run in different configurations. #My LED strips inside the neck are accidentally swapped left-right, #so these maps also correct for that #Bottom up along both sides at once pixel_map_reverse = PixelMap(pixels, [ 0, 103, 1, 102, 2, 101, 3, 100, 4, 99, 5, 98, 6, 97, 7, 96, 8, 95, 9, 94, 10, 93, 11, 92, 12, 91, 13, 90, 14, 89, 15, 88, 16, 87, 17, 86, 18, 85, 19, 84, 20, 83, 21, 82, 22, 81, 23, 80, 24, 79, 25, 78, 26, 77, 27, 76, 28, 75, 29, 74, 30, 73, 31, 72, 32, 71, 33, 70, 34, 69, 35, 68, 36, 67, 37, 66, 38, 65, 39, 64, 40, 63, 41, 62, 42, 61, 43, 60, 44, 59, 45, 58, 46, 57, 47, 56, 48, 55, 49, 54, 50, 53, 51, 52, ], individual_pixels=True) #Starts at the bottom and goes around clockwise pixel_map_around = PixelMap(pixels, [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, ], individual_pixels=True) #Radiates from the center outwards like a starburst pixel_map_radiate = PixelMap(pixels, [ 75, 73, 76, 27, 28, 74, 77, 26, 29, 73, 78, 25, 30, 72, 79, 24, 31, 71, 80, 23, 32, 70, 81, 22, 33, 69, 82, 21, 34, 68, 83, 20, 35, 67, 84, 19, 36, 66, 85, 18, 37, 65, 38, 86, 17, 64, 39, 87, 16, 63, 40, 88, 15, 62, 41, 89, 14, 61, 42, 90, 13, 60, 43, 91, 12, 59, 44, 92, 11, 58, 45, 93, 10, 57, 46, 94, 9, 56, 47, 95, 8, 55, 48, 96, 7, 54, 49, 97, 6, 53, 50, 98, 5, 52, 51, 99, 4, 100, 3, 101, 2, 102, 1, 103, 0, ], individual_pixels=True) #Top down along both sides at once pixel_map_sweep = PixelMap(pixels, [ 51, 52, 50, 53, 49, 54, 48, 55, 47, 56, 46, 57, 45, 58, 44, 59, 43, 60, 42, 61, 41, 62, 40, 63, 39, 64, 38, 65, 37, 66, 36, 67, 35, 68, 34, 69, 33, 70, 32, 71, 31, 72, 30, 73, 29, 74, 28, 75, 27, 76, 27, 77, 26, 78, 25, 79, 24, 80, 23, 81, 22, 82, 21, 83, 20, 84, 19, 85, 18, 86, 17, 87, 16, 88, 15, 89, 14, 90, 13, 91, 12, 92, 11, 93, 10, 94, 9, 95, 8, 96, 7, 97, 6, 98, 5, 99, 4, 100, 3, 101, 2, 102, 1, 103, 0 ], individual_pixels=True) #Every other pixel, starting at the bottom and going upwards along both sides pixel_map_skip = PixelMap(pixels, [ 0, 103, 2, 101, 4, 99, 6, 97, 8, 95, 10, 93, 12, 91, 14, 89, 16, 87, 18, 85, 20, 83, 22, 81, 24, 79, 26, 77, 29, 74, 31, 72, 33, 70, 35, 68, 37, 66, 39, 64, 41, 62, 43, 60, 45, 58, 47, 56, 49, 54, 51, 52, ], individual_pixels=True) pixel_map = [ pixel_map_reverse, pixel_map_around, pixel_map_radiate, pixel_map_sweep, pixel_map_skip, ] #Set up accelerometer & mic sensor = adafruit_lsm6ds.LSM6DS33(i2c) mic = audiobusio.PDMIn(board.MICROPHONE_CLOCK, board.MICROPHONE_DATA, sample_rate=16000, bit_depth=16) NUM_SAMPLES = 256 samples_bit = array.array('H', [0] * (NUM_SAMPLES+3)) def power_on(duration): """ Animate NeoPixels for power on. """ start_time = time.monotonic() # Save start time while True: elapsed = time.monotonic() - start_time # Time spent if elapsed > duration: # Past duration? break # Stop animating powerup.animate() def rockstar_tilt(duration): """ Tilt animation - lightning effect with a rotating color :param duration: duration of the animation, in seconds (>0.0) """ tilt_time = time.monotonic() # Save start time while True: elapsed = time.monotonic() - tilt_time # Time spent if elapsed > duration: # Past duration? break # Stop animating pixels.brightness = MAX_BRIGHTNESS pixels.fill(TILT_COLOR) pixels.show() time.sleep(0.01) pixels.fill(BLACK) pixels.show() time.sleep(0.03) pixels.fill(WHITE) pixels.show() time.sleep(0.02) pixels.fill(BLACK) pixels.show() time.sleep(0.005) pixels.fill(TILT_COLOR) pixels.show() time.sleep(0.01) pixels.fill(BLACK) pixels.show() time.sleep(0.03) # Cusomize LED Animations ------------------------------------------------------ powerup = RainbowComet(pixel_map[3], speed=0, tail_length=25, bounce=False) rainbow = Rainbow(pixel_map[4], speed=0, period=6, name="rainbow", step=2.4) rainbow_chase = RainbowChase(pixel_map[3], speed=0, size=3, spacing=15, step=10) rainbow_chase2 = RainbowChase(pixel_map[2], speed=0, size=10, spacing=1, step=18) chase = Chase(pixel_map[1], speed=0.1, color=RED, size=1, spacing=6) rainbow_comet = RainbowComet(pixel_map[2], speed=0, tail_length=80, bounce=True) rainbow_comet2 = RainbowComet( pixel_map[0], speed=0, tail_length=104, colorwheel_offset=80, bounce=True ) rainbow_comet3 = RainbowComet( pixel_map[1], speed=0, tail_length=25, colorwheel_offset=80, step=4, bounce=False ) strum = RainbowComet( pixel_map[3], speed=0, tail_length=25, bounce=False, colorwheel_offset=50, step=4 ) lava = Comet(pixel_map[3], speed=0.01, color=ORANGE, tail_length=40, bounce=False) sparkle = Sparkle(pixel_map[4], speed=0.01, color=BLUE, num_sparkles=10) sparkle2 = Sparkle(pixel_map[1], speed=0.05, color=PURPLE, num_sparkles=4) # Animations Playlist - reorder as desired. AnimationGroups play at the same time animations = AnimationSequence( rainbow, rainbow_chase, rainbow_chase2, chase, lava, rainbow_comet, rainbow_comet2, AnimationGroup( sparkle, strum, ), AnimationGroup( sparkle2, rainbow_comet3, ), auto_clear=True, auto_reset=True, ) MODE = 0 LASTMODE = 1 # start up in sound reactive mode i = 0 # Main loop while True: i = (i + 0.5) % 256 # run from 0 to 255 TILT_COLOR = colorwheel(i) if MODE == 0: # If currently off... enable.value = True power_on(POWER_ON_DURATION) # Power up! MODE = LASTMODE elif MODE >= 1: # If not OFF MODE... mic.record(samples_bit, len(samples_bit)) samples = np.array(samples_bit[3:]) spectrum = extras.spectrogram(samples) spectrum = spectrum[:128] spectrum[0] = 0 spectrum[1] = 0 peak_idx = numerical.argmax(spectrum) peak_freq = peak_idx * 16000 / 256 # print((peak_idx, peak_freq, spectrum[peak_idx])) magnitude = spectrum[peak_idx] # time.sleep(1) if peak_freq == 812.50 and magnitude > SOUND_THRESHOLD: animations.next() time.sleep(1) if peak_freq == 875 and magnitude > SOUND_THRESHOLD: if MODE == 1: MODE = 2 print("mode = 2") LASTMODE = 2 time.sleep(1) elif MODE == 2: MODE = 1 print("mode = 1") LASTMODE = 1 time.sleep(1) # Read accelerometer x, y, z = sensor.acceleration accel_total = x * x + y * y # x=tilt, y=rotate # print (accel_total) if accel_total > ROCKSTAR_TILT_THRESHOLD: MODE = 3 print("Tilted: ", accel_total) if MODE == 1: VOLUME = magnitude / (VOLUME_CALIBRATOR * 100000) if VOLUME > MAX_BRIGHTNESS: VOLUME = MAX_BRIGHTNESS # print(VOLUME) pixels.brightness = VOLUME # time.sleep(2) animations.animate() elif MODE == 2: pixels.brightness = NORMAL_BRIGHTNESS animations.animate() elif MODE == 3: rockstar_tilt(ROCKSTAR_TILT_DURATION) MODE = LASTMODE  

  • 发表了主题帖: LED夏威夷四弦琴

    来自:https://learn.adafruit.com/light-up-reactive-ukulele 夏威夷四弦琴易于演奏、轻便、轻巧,而且价格便宜。这款透明塑料夏威夷四弦琴用彩虹灯进行升级,为您的听众打造顶级的Tiki音乐体验。带有可自定义的动画和声音反应模式。使您的动画播放列表与歌曲曲目匹配,使音乐栩栩如生。 我们还使用了硬件的FFT功能为该项目添加了音符感知功能。只需在指板上敲一下特定的音符,即可更改动画模式或打开或关闭声音反应模式。         

  • 2020-08-07
  • 回复了主题帖: 又有板子开箱!这回是兆易GD32307E-START开发板

    就是不想多带数据线啊,miniUSB已经用的很少,以后线也不好找了。

  • 回复了主题帖: 使用nRF52840的自动化水族馆

    9zhmke 发表于 2020-8-7 11:44 因为之前的小型过滤器每周都得清洗,我已经把它删除了,换上个纯气泵,我就可以半年不去管它,水没黑之前 ...
    如果这样可以做个自动控制系统,定时打开和关闭,更加省心。

  • 回复了主题帖: 又有板子开箱!这回是兆易GD32307E-START开发板

    看到mini USB就无爱了。

  • 发表了主题帖: esp32 BLE 电机控制

    replyreload += ',' + 3000143;walecka在英文论坛分享的项目:esp32 BLE  电机控制   我刚刚用Micropython完成了我的第一个项目(以及我编写大量Python代码的第一次经验)。它允许用户通过BLE连接来调整PI控制直流电动机的速度、状态和方向。我还编写了一个同步任务计划程序。   原理图   项目链接   游客,如果您要查看本帖隐藏内容请回复

  • 回复了主题帖: 使用nRF52840的自动化水族馆

    9zhmke 发表于 2020-8-7 11:33 dcexpert 发表于 2020-8-5 20:53 清道夫效果也一般,还不如田螺效果好。 说清道夫效果一般的人,一 ...
    只要过滤循环系统正常,垃圾就可以控制。光照时间也需要注意,太长了就容易长青苔。

  • 回复了主题帖: 使用nRF52840的自动化水族馆

    ox000008 发表于 2020-8-7 10:56 养了一堆螺蛳,效果还不错。
    坛友中有不少也喜欢养鱼啊  

  • 2020-08-06
  • 回复了主题帖: Adafruit IO 时间追踪立方体

    freebsder 发表于 2020-8-6 22:18 挺有意思,紫色紫的还挺漂亮
    用的是WS2812,可以显示各种颜色

  • 回复了主题帖: 你们想要的GD32450I-EVAL哦~开箱晒图拉~~~

    Mbed也支持GD32450,只是不是这个开发板,而是另外一个类似Nucleo的GD32-F450ZI。  

  • 回复了主题帖: 今天的签到去哪了

    UUC 发表于 2020-8-6 11:03 论坛首页,头像下边是没有直接签到按钮的,点击用户名或用户组,可以进入后面这个有签到按钮的页面
    习惯了自动签到,手动签到很容易忘记

  • 发表了主题帖: Adafruit IO 时间追踪立方体

    来自Adafruit的创意DIY:https://learn.adafruit.com/time-tracking-cube 用一个可翻转的立方体让你的时间表保持有序。    

  • 回复了主题帖: 今天的签到去哪了

    okhxyyo 发表于 2020-8-6 09:19 在新版首页右侧能找得到哦。我们查下头部的签到丢失问题,谢谢
    没有自动签到功能了吗

  • 回复了主题帖: 分享一款国产32位M3单片机CH32F103

    看起来对标STM32F103了

  • 2020-08-05
  • 回复了主题帖: 自己做的板子无法下载程序

    trx007 发表于 2020-8-5 20:54 under reset 用这种方式,不行啊,另外我能在keil中识别到芯片那我的芯片应该没有被焊坏吧
    能识别出来一般应该没有问题,具体需要逐步排查分析,特别注意电源、复位、SWD等部分。

  • 回复了主题帖: 使用nRF52840的自动化水族馆

    9zhmke 发表于 2020-8-5 16:25        不知道为什么你们会担心青苔,你们不养清道夫的吗?       ...
    清道夫效果也一般,还不如田螺效果好。

  • 回复了主题帖: 有没有比CD4051更好用的模拟开关

    一般电平转换芯片都是1.8/3.3/5V转换的,高压的较少,可以用MOS或三极管转换,价格也低。

  • 回复了主题帖: 自己做的板子无法下载程序

    可以换RESET方式试试

最近访客

< 1/6 >

统计信息

已有2356人来访过

  • 芯币:49186
  • 好友:51
  • 主题:1427
  • 回复:7662
  • 课时:1
  • 资源:14

留言

你需要登录后才可以留言 登录 | 注册


Zmooc 2020-4-21
你好,我是一名学生,想请教一下你NUCLEO-F411RE这个板子的使用。由于是小白所以希望能获得您的帮助,如果您愿意帮助我。您可以留下你的QQ 或者微信。在这我留下我的QQ 2388548115. 如果有打扰到您 万分抱歉
久远寺有珠 2019-11-4
你们,我想请问一下可以用普通32用的1117-3.3来代替XC6206吗,除了大小以外还有什么要注意的地方吗
dcexpert 2019-4-7
和C语言中用法是一样的
szl123456 2019-4-6
您好 我正在在micropython上搞485通信,因为没有历程,大家好像都没搞过 大神能指导一下吗   help  help
werjufour 2018-8-28
你好!向你请教个问题。PIC24fj64ga004 AD转换值放在哪个寄存器当中?
dcexpert 2018-8-2
在《MicroPython中文教程》电子版和《MicroPython入门指南》一书中都有
15588608145 2018-8-2
具体的MicroPython所支持的模块和语法说明在哪里呢?
MSYuan0317 2018-7-27
您好!我们是代理乐鑫产品的,如果有需要可以联系我,QQ:285254096 ,谢谢!
dcexpert 2018-6-6
还没有开始做,等做好了我送你两片
mo2016 2018-6-6
DIY一个micropython的多功能无线电子钟 想要有偿PCB板二片,谢谢!
dcexpert 2015-1-22
不是5个DIY项目,是围绕DIY F429示波器,有5个小专题,希望大家一起讨论完成。

5个都在DIY示波器帖子中的。
xu__changhua 2015-1-22
5个DIY项目,我就查到示波器,还有4个能给出链接么?
查看全部