Arduino进阶教程:使用摇杆和按键操作OLED显示屏

Arduino 专栏收录该内容
¥59.90 ¥99.00
135篇文章

在这篇文章中,我们将介绍如何使用Arduino控制摇杆和按键,以及将其与OLED显示屏配合使用。我们将提供相应的源代码,以帮助您理解并实现这个项目。

材料准备:

  • Arduino开发板(如Arduino Uno)
  • 摇杆模块
  • 按键模块
  • OLED显示屏(支持I2C通信)
  • 杜邦线若干

连接电路:
首先,让我们连接电路。请按照以下步骤进行连接:

  1. 连接摇杆模块:

    • 连接摇杆的VCC引脚到Arduino的5V引脚。
    • 连接摇杆的GND引脚到Arduino的GND引脚。
    • 连接摇杆的X轴和Y轴引脚到Arduino的模拟输入引脚(例如A0和A1)。
  2. 连接按键模块:

    • 连接按键模块的VCC引脚到Arduino的5V引脚。
    • 连接按键模块的GND引脚到Arduino的GND引脚。
    • 连接按键模块的信号引脚到Arduino的数字输入引脚(例如D2)。
  3. 连接OLED显示屏:

    • 连接OLED显示屏的VCC引脚到Arduino的5V引脚。
    • 连接OLED显示屏的GND引脚到Arduino的GND引脚。
    • 连接OLED显示屏的SDA引脚到Arduino的SDA引脚(通常是A4)。
    • 连接OLED显示屏的SCL引脚到Arduino的SC
【雕爷学编程】Arduino动手做(38)---joystick双轴按键摇杆模块之摇杆X端控制舵机旋转角度 雕爷学编程,Arduino动手做,开源硬件,创客传感器,joystick双轴按键摇杆模块 阅读详情

相关推荐

【雕爷学编程】Arduino动手做(212)---9合1 扩展板完成Arduino的第10类扩展实验之0.96寸OLED12864液晶屏模块2

雕爷学编程,Arduino动手做,开源硬件,创客传感器,9合1 扩展板模块,0.96寸OLED12864液晶屏模块

雕爷学编程 1000

【雕爷学编程】Arduino月球基地之四向摇杆控制机械臂组合动作

然而,Arduino平台的硬件限制、专业性和深度方面的局限性,以及环境模拟的限制,可能对某些复杂任务和专业应用造成一定的限制。因此,在设计和实施Arduino月球基地场景时,需要根据实际需求和目标权衡这些局限性,并结合其他适当的教学工具和资源,以提供更全面和深入的学习体验。2、开放性和社区支持:Arduino是一个开放源代码的平台,拥有庞大的用户社区和资源库。5、创新:Arduino可以让你用电子的方式来表达你的创意和想象,你可以用Arduino来制作各种有趣和有用的项目,如机器人、智能家居、艺术装置等。

雕爷学编程 1311

PLC编程进阶:结构体(UDT)与功能块(FB)的模块化实践指南

本文深入探讨了PLC编程中实现模块化的核心方法,重点解析了结构体(UDT)与功能块(FB)的协同应用。通过将零散数据封装为UDT,并将控制逻辑打包为可复用的FB,能够构建出结构清晰、易于维护和调试的PLC程序。文章结合拧紧枪、电机控制等实战案例,提供了从设计原则到分层架构的完整实践指南,旨在帮助工程师将混乱的‘面条式’代码改造为高效的‘正规军’。

s3t4u的博客 221

GprMax正演模拟:为什么你的反射波‘消失’了?可能是直达波在捣鬼(附Python后处理脚本)

本文深入探讨了GprMax正演模拟中反射波信号被直达波淹没的现象,并提供了Python后处理脚本的实战指南。通过时域置零、自适应增益控制、频域滤波等多种技术,有效增强反射波信号,帮助用户解决探地雷达模拟中的常见问题。文章还包含详细的代码示例和效果评估方法,适合GPR数据处理的研究人员和工程师参考。

weixin_29305313的博客 232

SSE(Server-Sent Events)完整使用示例

本篇使用Node.js 作为服务端,在浏览器客户端演示SSE的完整实例和演示。实现了一个基于 Server-Sent Events (SSE) 的实时数据推送功能。

oscar999的专栏 750

GMSL转eDP芯片MAX9686X(ADI)

MAX96860/MAX96862/MAX96864解串器可以把单路或双路GMSL转换成eDP V1.4a,支持820MHzPCLK的无压缩的24bpp(每个像素的位数)视频,或660MHz的30bpp视频。芯片的GMSL支持NRZ编码的6Gbps/187Mbps的GMSL2,PAM4编码的12Gbps/187Mbps的GMSL3。同时支持单线(COAX模式)双向全双工传输控制数据和video数据。支持DSC压缩的芯片,最大支持像素时钟1080MHz@24bpp或者864MHz@30bpp,传输方式包括同轴

qflook的博客 2843

【QT开发教程】使用Qt进行蓝牙低功耗(BLE)编程

蓝牙低功耗(BLE,Bluetooth Low Energy)技术广泛应用于现代设备中,例如智能手表、健身追踪器和物联网设备。Qt提供了一套完整的Bluetooth模块,使开发者可以轻松地在应用程序中实现BLE通信功能。本文将介绍如何在Qt中进行BLE编程,包括基本概念、使用方法以及一些实际的示例。

科技改变人类,技术成就未来 2869

功能安全Safety Case构建方法论

本文系统阐述了功能安全认证中SafetyCase的构建方法。SafetyCase是一套结构化论证体系,通过Claim-Argument-Evidence(CAE)逻辑链证明系统安全性,包含系统级、技术安全级和实现级三层论证。文章详细介绍了SafetyCase的核心框架、与FMEDA等验证方法的关系、工程化实施步骤,以及常见失效模式。特别强调SafetyCase连接理论、实现与证据的桥梁作用,是功能安全认证的灵魂文件,要求将分散的安全活动组织成完整的逻辑论证。

VehSwHwDeveloper的博客 577

【个人学习总结】CRC校验原理及实现

CRC即循环冗余校验码(Cyclic Redundancy Check):是数据通信领域中最常用的一种查错校验码,其特征是信息字段和校验字段的长度可以任意选定。循环冗余检查(CRC)是一种数据传输检错功能,对数据进行多项式计算,并将得到的结果附在帧的后面,接收设备也执行类似的算法,以保证数据传输的正确性和完整性。 ..................

星Yeah 的博客 7967

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

IDEA的使用指南

IDEA基于java的使用手册,可以最快速的上手,在使用中不断的丰富自己的使用技巧.

华为的C语言编程规范.pdf

华为技术有限公司内部技术规范。本规范制定了编写C语言程序的基本原则、规则和建议。从代码的清晰、简洁、可测试、安全、程序效率、可移植各个方面对C语言编程作出了具体指导。

上一篇: 搭建Arduino ESP32开发环境
下一篇: Arduino最小系统烧录问题解决方案
普通网友
博客等级 码龄3年 116粉丝 0原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值