<issue_start>username_0: I recently reinstalled macOS Monterey (12.0.1) on my MacBook Air (Intel, 2020) and restored data from my Time Machine backup; APFS format.

That went well, but after I did this it seems like my external storage drive, named “Storage”, now has an older clone next to it called “Storage 1” in recent snapshots. See screenshot below of snapshot `2021-11-26-113550`.

I assume some kind of identifier for the system and drive itself changed when the restore happened. I am fine with that. But this fairly useless — and redundant — “Storage 1” is taking up about 700GB of space.

I can’t seem to just delete it as a Time Machine backup is “Read Only” to the Finder and Terminal since this is the newer Time Machine format that uses APFS and snapshots instead of HFS+ and a standard filesystem scheme.

What can I do to toss this “Storage 1” folder in the snapshots and free up that 700GB?

[![enter image description here](https://i.stack.imgur.com/kV98h.png)](https://i.stack.imgur.com/kV98h.png)<issue_comment>username_1: With Time Machine to APFS (TMA), it is not possible to delete particular folders inside any Time Machine snapshots. This is the only downside of the change from TMH (Time Machine to HFS) to TMA.

It is possible to delete whole snapshots from TMA using `tmutil` command. I have done this under Big Sur, but I have seen some doubts cast on whether this is still possible for Monterey. But deleting whole snapshots is not what you are wanting.

I suggest you start with a new Time Machine disk/volume and, at some point, discard your old backups. With sufficient free space on your existing TM disk you can create a new volume in Disk Utility and start a new Time Machine backup to that. Otherwise you need another physical disk.
Upvotes: 2 [selected_answer]<issue_comment>username_2: You can use `tmutil associatedisk` to associate the old storage backup directory with the active drive and that will allow Time Machine to carry the old backup history and avoid the duplicate entry:

```
sudo tmutil associatedisk /Volumes/Storage "/Volumes/{TimeMachineDrive}/Backups.backupdb/{MachineDirectory}/Latest/Storage 1"

```

Or if you just want to get rid of the "Storage 1" backup and don't care about the history, you can use the earlier command, but instead, associate the "Storage 1" directory with a volume that is excluded from backups.

For example plug a USB drive e.g. `/Volumes/USB`, it should be automatically excluded from backups by Time Machine. Then you can run:

```
sudo tmutil associatedisk /Volumes/USB "/Volumes/{TimeMachineDrive}/Backups.backupdb/{MachineDirectory}/Latest/Storage 1"

```

In the next backup, Time Machine will wipe the "Storage 1" directory.
Upvotes: -1


<issue_start>username_0: I'm thrilled to find Navddeep's solution here [How to convert an epub package to regular epub?](https://apple.stackexchange.com/questions/239050/how-to-convert-an-epub-package-to-regular-epub/429474#429474) yet two essential questions arise as I try to implement it.

1. What in the string must I change to identify my unique paths, or anything else?
2. How can I convert this string—not yet a py file—into something I can test and use as an executable? I'm driving Catalina on a MacBook Pro. I've worked in Mac IT for 20 years but I'm no coder and I'm certain Applescript hates me.The Python string is below.

```py
# Convert epub packages to epub files
import os
import subprocess

filenames = []
path_to_files = ""
#   Function to store all filenames in a list
def extract_filename(path_to_files):    # "/Users/****/Desktop/Old_epubs"
    os.chdir(path_to_files)
    books = os.getcwd()
    for f in os.listdir(books):
        f_name, f_ext = os.path.splitext(f)
        if f_ext == ".epub":
            filenames.append(f_name)

    filenames.sort()

#   Function to generate new epub files
def create_epub(path_to_new_files): # "/Users/****/Desktop/new_epubs/"
    total_files = len(filenames)
    for i in range(total_files):
        epub_path = "cd " + path_to_files
        filename = filenames[i] + ".epub"
        zipping = " zip -X -r " + path_to_new_files + filename + " mimetype *"
        plist = "rm iTunesMetadata.plist"
        comm = epub_path + filename + "; " + plist + "; " + zipping
        p1 = subprocess.run(comm, capture_output = True, text = True, shell = True)
        success = p1.returncode
        if success == 0:
            rem_files = total_files - i + 1
            print("File #", i+1, " has been processed successfully. Remaining files: ", rem_files)

#   Enter the paths
extract_filename("/Users/****/Desktop/Books")   # Path to directory containing epub packages
create_epub("/Users/****/Desktop/new_epubs/")   # Path to store new epub files in

```<issue_comment>username_1: The "string" is not a string. It is just text on a page as if you were reading a book.

The text if copied to a new file is a python program.

The steps are

1. Copy the text into a new file in a text editor e.g. TextEdit or nano
2. Save the file as convert.py or another filename ending in .py The suffix is the standard for python files.
3. Edit the last two lines to alter the paths for input directory and the output epub file respectively and save
4. In a Terminal change directory to the directory you saved the python file in.
5. In Terminal run `python convert.py` Or what ever you named the file as

I think this code works as python2 so will work with the Apple installed python - however if not you need a python3 and the easiest way is to install this via installing Xcode and its command line tools. You then need to run the command line as `python3 convert.py`

As a programming note I would not be using the subprocess.run to deletete things and zip the file. I would use that using python functions

The other answer <https://apple.stackexchange.com/a/372808/237> is probably easier to deal with. Just run the given command in the terminal
Upvotes: 1 <issue_comment>username_2: regarding point 1:
it seems you should change `path_to_files = ""` to `path_to_files = "path\to\your\folder\where\the\books\are"` and thats it

regarding point 2:
The simplest solution is to create a new text file, past the code into it and run `$ python new_file`
If you are reluctant to create a file, you can type in your terminal `python -c '`, then paste the text, and finally add another quote `'` mark and press enter
Upvotes: 0 <issue_comment>username_3: If anyone else on a Mac needs to do this yet struggles with Python I found a much easier solution [here](https://www.reddit.com/r/Calibre/comments/dza1zi/how_do_i_package_files_from_ibooks_own_files_not/). It's a little tedious for large libraries but it had my 1,300 titles sorted in a couple of hours with no frustrations.
Upvotes: 0


<issue_start>username_0: Apparently I hit some shortcut combination that caused Slack to automatically collapse the sidebar that contains the list of Channels and Direct Messages.

[![enter image description here](https://i.stack.imgur.com/bmLjvm.png)](https://i.stack.imgur.com/bmLjvm.png)

There is an option to **temporarily** show the Sidebar in the View menu:

[![enter image description here](https://i.stack.imgur.com/VVCF4m.png)](https://i.stack.imgur.com/VVCF4m.png)

we now temporarily see the left sidebar

[![enter image description here](https://i.stack.imgur.com/REVPsm.png)](https://i.stack.imgur.com/REVPsm.png)

But after clicking in conversation area the sidebar will still hide itself again.

[![enter image description here](https://i.stack.imgur.com/hRNsIm.png)](https://i.stack.imgur.com/hRNsIm.png)

I have looked at Preferences | Sidebar and it does not have any setting related to hide/show:

[![enter image description here](https://i.stack.imgur.com/xK7DCm.png)](https://i.stack.imgur.com/xK7DCm.png)

Is there any way to do a "factory reset" on the Slack settings but retain the existing channels? In other words I do not want to completely reinstall Slack unless necessary.<issue_comment>username_1: Often time, especially on the web and apps that use macOS to just wrap their web content into a neat package. Just making the window **w i d e r** (if it's a side bar instead of a top/bottom bar) will often make room for the sidebar to expand.

This works on youtube.com and I am wondering if that might be what is going on here as well...
Upvotes: 2 <issue_comment>username_2: This could also be because of zoom in. I had a similar issue and when used the default (100%) zoom, things worked fine.

You could find zoom option on
top right(your image) -> Preferences -> Accessibility
Upvotes: 2 <issue_comment>username_3: There is now a setting for this in the Sidebar Preferences:
[![enter image description here](https://i.stack.imgur.com/DNpXP.png)](https://i.stack.imgur.com/DNpXP.png)

Simply keep that unchecked to prevent the sidebar from collapsing if you shrink the Slack window.
Upvotes: 3 [selected_answer]


<issue_start>username_0: I am using this command to install app in macOS Monterey(the apple M1 pro chip), but facing a problem like this:

```
➜  ~ brew install --cask dbeaver-community
==> Downloading https://dbeaver.io/files/21.3.2/dbeaver-ce-21.3.2-macos-aarch64.dmg
Already downloaded: /Users/xiaoqiangjiang/Library/Caches/Homebrew/downloads/c4fed662e860fd6ca0099f59da082b651e219af2b3369c1f85363dbc7469d1f2--dbeaver-ce-21.3.2-macos-aarch64.dmg
==> Installing Cask dbeaver-community
==> Purging files for version 21.3.2 of Cask dbeaver-community
Error: It seems there is already an App at '/Applications/DBeaver.app'.

```

is it possible to override the old app using homebrew but keep the old app config?<issue_comment>username_1: using this command fix it:

```
➜  ~ brew install --cask dbeaver-community --force
==> Downloading https://dbeaver.io/files/21.3.2/dbeaver-ce-21.3.2-macos-aarch64.dmg
Already downloaded: /Users/xiaoqiangjiang/Library/Caches/Homebrew/downloads/c4fed662e860fd6ca0099f59da082b651e219af2b3369c1f85363dbc7469d1f2--dbeaver-ce-21.3.2-macos-aarch64.dmg
==> Installing Cask dbeaver-community
Warning: It seems there is already an App at '/Applications/DBeaver.app'; overwriting.
==> Removing App '/Applications/DBeaver.app'
==> Moving App 'DBeaver.app' to '/Applications/DBeaver.app'
  dbeaver-community was successfully installed!

```
Upvotes: 5 [selected_answer]<issue_comment>username_2: Repeating the following commands resolved the issue for me:

```
brew outdated
brew reinstall foo

```

2 wild output appeared:

```
Warning: It seems there is already an App at '/opt/homebrew/Caskroom/foo/21.3.2/foo.app'; overwriting.

```

and

```
Error: bar: Directory not empty @ dir_s_rmdir - /Applications/Bar.app

```

The wild Warning ran, so I could ignore it. But against the Error I had to fight. I figured, that the brew user did not have write permissions in a [multi-user brew setup](https://stackoverflow.com/questions/41840479/how-to-use-homebrew-on-a-multi-user-macos-sierra-setup) on that file. Deleting the file (with `sudo` or as a user or group member with write permissions) and then using `brew reinstall` led to get away safely from that Error.

Alternatively, one could probably change the owner of that file with the `sudo` and `chown` command and execute `brew reinstall` or `brew install --force`.
Upvotes: 1


<issue_start>username_0: I have a presentation in PDF and I want it on full screen. How to get one?

When I use Preview full screen or slideshow I always get that black frame. I previously have had presentations in PowerPoint and there it works without any problems. What do I do now that I have a pdf?

How my screen looks like:

[![enter image description here](https://i.stack.imgur.com/XandP.png)](https://i.stack.imgur.com/XandP.png)

(I added the white box with black frame to hide the content of my slides, but that is not important, I want to know how to hide this thick black frame around it)<issue_comment>username_1: Full Screen should work for Preview in the same way as any other app. Obviously, the 'background' outside of the page will be dark, but if the PDF page is zoomed to match, then you won't see any black edge.
Upvotes: 0 <issue_comment>username_2: This seems to be a feature of Preview in Monterey.

You may want to use a 3rd party PDF viewer instead. I tried with [Skim](https://skim-app.sourceforge.io/), it uses the full screen in presentation mode.
Upvotes: 1


<issue_start>username_0: The Monterey 12.3 upgrade removes [Python 2.7](https://developer.apple.com/documentation/macos-release-notes/macos-12_3-release-notes#Python) with no user warnings. Homebrew only knows about Python 3. What other ways are there to get Python 2 back up and running?

I'm not interested in hearing arguments about deprecation. We're not a dev shop, just a small mail order business with some internal scripts that need to work again.<issue_comment>username_1: The [Python Release Python 2.7.18 | Python.org](https://www.python.org/downloads/release/python-2718/) download page has a macOS 64-bit installer download that replaces the missing interpreter.
Upvotes: 5 [selected_answer]<issue_comment>username_2: MacPorts packages python27.

I also found an [unofficial tap](https://github.com/kamilturek/homebrew-python2), if you must use Homebrew for some reason, in about 10 sec of searching.
Upvotes: 2


<issue_start>username_0: I am using Photos on macOS 12.3 choosing the Places album.

I get the map and can expand it so I get a thumbnail photo with a number for the number of photos in that area.

Then I double click on the thumbnail - the first couple of times it switches to a view with all the photos for that area in a grid. However after expanding and going back a few times when I double click on a thumbnail nothing happens. Well the cursor switches from the pointer to a hand so you can drag the map.

How do I reliably get from the Places album to the grid view.<issue_comment>username_1: Double click zooms, single click is enough.
Upvotes: -1 <issue_comment>username_2: The issue is that whenever I click the mouse is not totally still.

Thus if I click once it starts a click and drag.

If I go through contortions to make the mouse totally still then I do get the places expanding.

This is a real accessibility problem,
Upvotes: 1 [selected_answer]


<issue_start>username_0: I have a strange situation, which has now occurred with two browsers (Chrome and Edge). I'm running MacOS 11.6.5 on a Macbook Pro 13" 2017.

After a while of running with no issue, I will try and use a different application - could be anything, iTerm, VirtualBox, Teams, Slack, Finder, whatever - but the browser will still appear to take the focus, even if I minimise or hide the browser window.

What it looks like:
[![enter image description here](https://i.stack.imgur.com/9bJcJ.png)](https://i.stack.imgur.com/9bJcJ.png)

What it means is that I cannot actually click on buttons or enter text in any other application when this happens - tremendously annoying.

The only way I have found to actually use any other application in this situation is to quit the browser application completely. Closing windows, minimising, hiding, don't work.

Does anyone know why this happens, or what I can do to troubleshoot further?

---

**Update**: just closing the browser isn't enough to fix the problem, interestingly. If I re-open the browser, it happens straight away. I need to reboot to be able to go back to fully working normal state.<issue_comment>username_1: I don't have a neat solution.

In my case, the problem happens when I try to sync my Google account in System Preferences. When opens the browser in order to authenticate, all programs lose focus except the browser, having the same annoying behaviour if I close and reopen the browser again. When I cancel the sync process and quit System Preferences, sometimes works normal again.

But, all the focus problem seems to be related to the **SafariLaunchAgent** process. As Activity Monitor also loses focus until the navigator closes, I quit the navigator and then kill that process, saving me a reboot.
Upvotes: 3 <issue_comment>username_2: I have the same problem and have found a workaround, which is to make Safari your default browser until you're done linking accounts:

1. Go to **System Preferences** > **General**, set **Default Web Browser:** to **Safari**
2. Go to **System Preferences** > **Internet Accounts**, update passwords via Safari OAUTH flow
3. Set **Default Web Browser** back to what it was.

Apple must have introduced this bug recently via the SafariLaunchAgent mentioned above.
Upvotes: 3


<issue_start>username_0: I have an external hard drive that is APFS encrypted, but I also tested this with an APFS drive that is not encrypted.

Simply put, I mount my hard drive, view some files via quicklooking (press space on the item) or launch them into VLC, then eject the drive. There is a catch, and that most of the times I do this, I have to force quit all quicklook tasks via activity monitor. The error actually just says it's being used (doesn't say what task) and gives me a prompt to wait, cancel, or force eject.

So, how can I make it so quicklook isn't always preventing my hard drive from ejecting and 'yank it out' preferably shouldn't be a solution. None of the files are applications, but dmg files that I look through, and yes; I've ejected everything or closed every window before ejecting the drive.<issue_comment>username_1: Before trying to eject your hard drive, make sure none of the files you "quicklooked" from your external hard drive are currently selected.

If any of the files from your external hard drive are currently running in VLC or any other app., those files need to be closed before you can eject the external hard drive.

If you still cannot eject your external hard drive after my first 2 suggestions. open Terminal.app and enter this command `killall -KILL Finder`

That will kill and relaunch Finder, which should also kill any stubborn quick look processes which are stopping you from ejecting your external hd.

If this happens often enough, you may consider creating a new Automator quick action and add a "Run Shell Script" command to the workflow and use the code from above. Then you could assign a keyboard shortcut to your new Quick Action, in System Preferences.

[![enter image description here](https://i.stack.imgur.com/cvIEa.png)](https://i.stack.imgur.com/cvIEa.png)
Upvotes: 0 <issue_comment>username_2: I don't have an answer for how to prevent QuickLook from keeping a file on the disk open in the first place; this has been a bug with QuickLook for a very long time.

I have to execute this command every time QuickLook prevents eject:

```
killall -9 QuickLookSatellite

```

Then I can eject the disk.
Upvotes: 2


<issue_start>username_0: It is a bit strange that in the File -> Export of Logic Pro, I can export all tracks into one file, but only as Wav, Aiff, CAF format.

However, I can share to Apple Music, and it will go into the Music app as .m4a

I can share to SoundCloud, and the upload is quite fast, so I think it is either .m4a or .flac or .mp3. (I just tried downloading my own file, and it was .m4a, but why upload first and download? And SoundCloud sometimes mark our own playing of classical piano music as "possible infringement of copyright" and won't include our work in our profile).

So how do we just save it as one of .mp3, .flac, or .m4a format without going through Apple Music or SoundCloud?<issue_comment>username_1: You can export the track to different codecs by hitting File -> Bounce and select the appropriate options.
Upvotes: 0 <issue_comment>username_2: Export is for your master file, not for lossy compressed formats. Save your master as WAV or AIF, then convert for streaming services as a separate step. The two structures also demand different mastering levels. 'CD' can have far higher LUFS values than streaming, so you master first for CD, then pull your levels back to satisfy -14dB LUFS streaming limits & be more careful monitoring for TruePeak levels, which are not so important for WAV as for compressed formats, where they can cause distorted peaks.
Upvotes: 1


<issue_start>username_0: I have a MacBookAir7,2 that's been with me since around 2016/2017. I don't remember the exact year.

It has a Dual-Core Intel Core i5 processor at 1.6GHz. It used to have High Sierra version then I upgraded it to Monterey 12.6.0 just few days ago.

It started all good with Monterey but now started lagging ever since I installed the 12.6.1 update.

I tried updating it to version 12.6.1 but it seems to get stuck at **15 minutes** remaining. Not really getting through the update.

How to fix the lagging issue of MacOS 12.6.0? Is this one of those planned obsolescense?<issue_comment>username_1: **Is this one of those planned obsolescence?**

No. If you Mac is supported by a new OS, then it should work, and it should work well. *(If Apple can't get an OS to run well on a Mac model, then they exclude it from the OS.)*

Problems after upgrading are often caused by third-party software that is incompatible with the new OS. It may need upgrading, or removing.

Jumping several 'years' in one go is more likely to make this happen.

I would recommend using an app like EtreCheck, which provides you with a report of all the software that might affect system performance. You can then check whether you need everything it lists, or whether it needs updating to a newer version.

<https://etrecheck.com/en/index.html>

You can post the report here, in your question, if you'd like. It does not contain any identifying or unique information.
Upvotes: 2 <issue_comment>username_2: Try restarting into [Safe Mode](https://support.apple.com/guide/mac-help/start-up-your-mac-in-safe-mode-mh21245), then booting again normally. This will flush various caches and is always a good troubleshooting step.

Then open System Preferences > Users & Groups, and try removing all entries from the Login Items section. Log out and log back in and see if the lagging behavior persists.
Upvotes: 0


<issue_start>username_0: I have already uninstalled Microsoft Defender following Microsoft [instructions](https://learn.microsoft.com/en-us/microsoft-365/security/defender-endpoint/mac-resources?view=o365-worldwide#uninstalling):

>
> Interactive uninstallation
>
>
> Open Finder > Applications. Right click on Microsoft Defender for Endpoint > Move to Trash.
>
>
>

Defender is not in my Applications folder anymore.

However, **System Settings** > **Network** > **Filters** > **Filters & Proxies** still show Microsoft Defender, and it is enabled but with a yellow dot.

[![enter image description here](https://i.stack.imgur.com/8bHYf.png)](https://i.stack.imgur.com/8bHYf.png)

This filter does not have enabled the option to disable.

Any suggestion how to get rid of this filter?

**Update:** after restarting the machine, the icon is gone, but filter/proxy still shows up:

[![enter image description here](https://i.stack.imgur.com/oQpy7.png)](https://i.stack.imgur.com/oQpy7.png)<issue_comment>username_1: Sorting works differently than filtering. Assuming sorting is one of the last few actions you have taken in that Numbers file and you have not quit the file after sorting, just press `Command`+`Z` (a few times if sorting was not the very last action) to take it back.
Upvotes: 0 <issue_comment>username_2: There is no 'restore order before sorting' (except limited possibility of undo already mentioned) but there is [restore previous version of file](https://support.apple.com/guide/numbers/restore-an-earlier-version-of-a-spreadsheet-tan7f1de6ec5/mac)

>
> Every time you save a spreadsheet, Numbers saves it as a new version.
> As a result, you can browse earlier versions, save a copy of an
> earlier version, or restore a spreadsheet to an earlier version.
>
>
>

So if you have saved version with desired order you can restore it or copy from that, just go to File > Revert to > Browse all versions
Upvotes: 2


<issue_start>username_0: In the past it was possible to set the account picture from a image file on the disk.
You'd drag the images from Finder to the user account picture, and voila it's done.

But this doesn't work on Ventura (13.1). Dragging the image doesn't do anything.

Is there something broken or is there a different procedure.

[screen recording](https://imgur.com/YHD9bK2.mp4)<issue_comment>username_1: You're doing the right procedure:

>
> Tip: To quickly replace the current Apple ID picture with an image on your Mac, just drag the image from the Finder onto the current picture.
>
>
>

<https://support.apple.com/guide/mac-help/mtusr002/mac>

However, there's only one drop zone that appears to work: the one from the ⓘ button.

![](https://imgur.com/0PozLE1.mp4)
Upvotes: 4 [selected_answer]<issue_comment>username_2: Because @username_1's answer was too terse and wrong (there are are least 2 places you can drop an image, not one)

The instructions on the Apple site are arguably wrong, at least on Ventura 13.1. ([See video](https://www.youtube.com/watch?v=OzPchZZeOWc)) as in the context of Apple's instructions this is the current picture.

[![enter image description here](https://i.stack.imgur.com/Ypht6.jpg)](https://i.stack.imgur.com/Ypht6.jpg)

There are at least 6 places where your "current picture" appears but only two of them work. You can see at 5 places where your "current picture" appears in these screenshots (1: left panel, 2: apple id, 3: users and groups list, 4: info dialog, 5: the select icon dialog)

1. Pick account

[![enter image description here](https://i.stack.imgur.com/IYQZV.png)](https://i.stack.imgur.com/IYQZV.png)

This will then bring up the dialog that lets you select an icon but the icon on the left will be filled with the image you just dropped so you can just click "Save"

2. From System Settings pick "Users and Groups" then click the ⓘ button

[![enter image description here](https://i.stack.imgur.com/tXVWH.png)](https://i.stack.imgur.com/tXVWH.png)

Then drag an image to the icon

[![enter image description here](https://i.stack.imgur.com/4pA3G.png)](https://i.stack.imgur.com/4pA3G.png)
Upvotes: 3


<issue_start>username_0: I found some stains on my MacBook Pro M1 2020 display glass at the top of the screen. They won't go away with regular cleaning. I'm worried about how they look and if they'll cause problems.

Can anyone suggest simple ways or products clean these stains off my laptop screen? Also, how can I stop this from happening again?

[![macbook-display-glass](https://i.stack.imgur.com/Ny5gE.jpg)](https://i.stack.imgur.com/Ny5gE.jpg)

*I've hardened up the contrast a lot in this & cropped to the most significant area, to make it easier to see…*

[![enter image description here](https://i.stack.imgur.com/BfbhL.jpg)](https://i.stack.imgur.com/BfbhL.jpg)<issue_comment>username_1: The [Homebrew formula](https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/buf.rb) used to install `buf` has a dependency to the Homebrew `go` package, this will trigger the installation of Homebrew's `go` if it isn't installed via Homebrew yet.

```
...
  depends_on "go" => :build

  def install
    %w[buf protoc-gen-buf-breaking protoc-gen-buf-lint].each do |name|
      system "go", "build", *std_go_args(ldflags: "-s -w", output: bin/name), "./cmd/#{name}"
    end

```

To avoid a duplicated `go` installation, you can either install `go` via Homebrew only, or roll your own formula for `buf` which doesn't depend on the `go` package.
Upvotes: 2 <issue_comment>username_2: tl;dr You don't need build dependencies to install packages [from a Bottle](https://docs.brew.sh/Bottles).

I didn't require Go installed, Homebrew or otherwise, to install buf.

---

Let's start with `brew info buf` to see what we're working with

```
$ brew info buf
==> buf: stable 1.15.1 (bottled), HEAD
…
==> Dependencies
Build: go ✘
==> Options
…
==> Analytics
…

```

The two key pieces of information here are

>
>
> ```
> ==> buf: stable 1.15.1 **(bottled)**, HEAD
> ```
>
>

>
>
> ```
> Build: go ✘
> ```
>
>

This tells us:

* buf is available in a bottle

>
> Bottles are simple gzipped tarballs of compiled binaries.
>
>
>

https://docs.brew.sh/Bottles
* building `buf` depends on `go`, which is not installed with Brew (hence `✘`).

This means you don't need to install `go` just to install `buf` from a bottle, as I was successfully able to do:

```
$ brew install buf
==> Fetching buf
==> Downloading https://ghcr.io/v2/homebrew/core/buf/manifests/1.17.0
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/buf/blobs/sha256:b190b169d11d6acb1d81d9da47c1369074ee50deee237e4c544ca79731c78b6a
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:b190b169d11d6acb1d81d9da47c1369074ee50deee237e4c544ca79731c78b6a?se=2023-04
######################################################################## 100.0%
==> Pouring buf--1.17.0.ventura.bottle.tar.gz
==> Caveats
fish completions have been installed to:
  /usr/local/share/fish/vendor_completions.d
==> Summary
  /usr/local/Cellar/buf/1.17.0: 86 files, 56.0MB

$ buf -h
The Buf CLI

A tool for working with Protocol Buffers and managing resources on the Buf Schema Registry (BSR)

…

```

If your install is building from source, see ‘Bottles will not be used if:’ section of <https://docs.brew.sh/Bottles>.

---

If you want to install a package with Homebrew and you know you don't need its help in installing dependencies, you can always use `--ignore-dependencies` with `brew install`.
Upvotes: 3 [selected_answer]


<issue_start>username_0: On MacOS Monterey:

I have downloaded the [*JetBrains Mono* typeface](https://download.jetbrains.com/fonts/JetBrainsMono-2.304.zip?_gl=1*pc4fvi*_ga*MTc5NTgyNDY1NS4xNjg2MTM1MjIy*_ga_9J976DJZ68*MTY4NjEzNTIyMS4xLjEuMTY4NjEzNTQyMS42MC4wLjA.&_ga=2.169561698.276122232.1686135222-1795824655.1686135222). This is a zip-file containing 69 TTF-files. How can I add them to MacOS? The JetBrains website shows in their installation instructions only how to install them for their IDE, which I don't plan to use.

I found an [Apple Support Page](https://support.apple.com/en-us/HT201749), which explains how to install a single font file: Use Finder to open the font directory and then do a double click on the font file.

Do I have to repeat this 69 times for all files, or is there a simpler way?<issue_comment>username_1: I found a solution using the application `Font Book`:

1. Open Font Book
2. Click on the left side pane on "All Fonts"
3. Use the menu "File/AddFonts"
4. Navigate to the directory having the fonts
5. Select all fonts (using Apple-A)

The crucial point is here item 2. If **All Fonts** is not selected, the *Add Fonts* menu item might be greyed out (at least this was the case for me).
Upvotes: 0 <issue_comment>username_2: * Open Font Book
* Drag&drop all font files into it

or

* Select all fonts in Finder
* Right-click on selection and select “Open“
Upvotes: 2 <issue_comment>username_3: There are several way you can do it.

Select all in Finder. Right click > Open with > FontBook

[can't have any folders selected this way, just fonts.]

If Font Book is already open…

Drag & drop the entire folder onto Font Book.

*or*

Use the Open menu in Font Book & select the entire folder in the file picker.

These last two methods will ignore folders, text files etc & just import the useable fonts.
Upvotes: 3 [selected_answer]<issue_comment>username_4: You can also just drag the fonts into `/Library/Fonts` or `~/Library/Fonts` (the user library) in the Finder, bypassing FontBook altogether.

They can be in a subfolder, to maintain organization, if you want.
Upvotes: 1 <issue_comment>username_5: If you're looking for a way to install the fonts programmatically (without having to reach for the mouse) this is the method I use:

<https://github.com/username_5/font-installer>

The script checks the locally-installed font version, compares it with the latest available from GitHub, and downloads and installs the fonts if necessary.

@username_4: Not sure what to make of your comment. Homebrew's pretty common, and the script is provided as an example—the dependencies could be removed if necessary.
Upvotes: 1


<issue_start>username_0: I have a disability that makes it difficult for me to double-click quickly enough to be detected, even after setting double-click speed as slow as possible.

[![screenshot showing Double-Click speed slider set all the way to the slowest extreme](https://i.stack.imgur.com/5xBDC.png)](https://i.stack.imgur.com/5xBDC.png)

Is it possible to set it even slower or program a mouse button or key combination to trigger a double-click?

I am using a MacBook Pro (2019) with OS 12.6.5 Monterey.

**Edit**

Commenter Alan helpfully pointed me to [Accessibility Settings specific to the mouse/trackpad](https://support.apple.com/en-gb/guide/mac-help/unac899/13.0/mac/13.0). While that did not enable me to make the speed slower or to assign a key to double-click, it does support setting a facial expression or using a hardware switch, which I can presumably purchase. I successfully set it to register a double-click when I stick out my tongue, which does properly express how I feel about the limitations on speed but is not suitable for when I am teaching online. I will look into buying a switch but would still welcome other hacks that would work with the existing hardware (keyboard or mouse).<issue_comment>username_1: After comments…

Replacing a standard mouse with any that features an extra button inside the scroll-wheel itself would then allow you to set that as double-click [or, in fact, *any* extra button over the standard 2+wheel].

This is a feature of many 'premium' mice. The mouse itself may come with appropriate controlling software to allow you to set this assignment. If not, there is 3rd party software such as [SteerMouse](http://plentycom.jp/en/steermouse/) or
[USB Overdrive](https://www.usboverdrive.com) which can enable this [& much more] functionality.

This is a screenshot of part of my own Logitech Options mouse control panel, showing just such a feature, which I have been using in various forms for 30 years, for similar reasons.

[![enter image description here](https://i.stack.imgur.com/yI4DP.png)](https://i.stack.imgur.com/yI4DP.png)
Upvotes: 3 [selected_answer]<issue_comment>username_2: I asked the same question on the [Disabled Techies Slack](https://invite.disabledtechies.org/join) and was told about [Better Touch Tool](https://folivora.ai/), which enables mapping many different actions (keypresses, touchpad touches, trackpad actions, mouse clicks) to different actions, including double-click.
Upvotes: 0


<issue_start>username_0: I have an Arduino Yún, and it only has 16mb flash onboard for the Linux. I was wondering of it is possible to put a bootloader on the flash that uses the sd card as a rootfs? i want to be able to do more projects on it than those that can fit in 16 MB flash.<issue_comment>username_1: I am using Yun as well for my projects. I don't boot from SD card, but I store a lot of Python code there and it works for me. I've also seen this article that might be interesting for you. I haven't tried to do it on my Yun but I think it should work... This is example how to install node.js on the Yun (SD card), so in theory you could use the same approach for all additional software you want to run.

[http://linino.org/doku.php?id=wiki:nodejs](http://linino.org/doku.php?id=wiki%3anodejs)
Upvotes: 2 <issue_comment>username_2: And the Arduino team finally figured it out:

<http://blog.arduino.cc/2014/05/06/time-to-expand-your-yun-disk-space-and-install-node-js/>
Upvotes: 4 [selected_answer]


<issue_start>username_0: I'm trying to figure out how to create some non-blocking code to strobe some RGB leds with analogwrite 7 times a second; I'm really not to sure how to go about this. If anybody could give me some help that'd be great! :)<issue_comment>username_1: What you want can be achieved with your MCUs timers and their associated interrupts. Timers are basically counters that run inside your hardware and they run decoupled from your code. Since one usually knows how fast these timers tick (e.g. how long it takes to count from one to two and so on) you can specify events that happen when a certain amount of timer ticks passed.

I suggest you have a look at [SimpleTimer](http://playground.arduino.cc/Code/SimpleTimer) and [Timer1](http://playground.arduino.cc/Code/Timer1) (the second page is only for ATmega168/328)

Both pages include some code samples where they specify some method that will be called every x milliseconds.
Upvotes: 2 [selected_answer]<issue_comment>username_2: Timers are the best way to go, (much) less overhead and you don't have to worry about it elsewhere in your code (other than managing variable use between your main loop and your ISRs).

But I do have a habit of doing things the hard way in code first and then move to timers once I've got it the way I'd like.

Here is sample code to flash the on board LED X times per second, I have calculated it to mean, ON 7 times per second and OFF 7 times as well (meaning, there is a change of state 14 times per second).

This code isn't efficient, it doesn't take into consideration that the value is already set or not, it just writes the value that it should be right now.

Finally, to go to analogWrite and use PWM, just change:

```
digitalWrite(LED, HIGH);

```

to

```
analogWrite(NEW_PIN, PWM_VALUE);

```

code:

```
#define LED               13
#define TIMES_PER_SECOND  7

const int M1 = 1000 / TIMES_PER_SECOND;
const int M2 = 1000 / TIMES_PER_SECOND / 2;

void setup(){
  pinMode(LED,OUTPUT);
}

void loop(){
  if(millis()%M1
```

Remember there is overhead with digital (and analog) writes, so (as I mentioned) you could check to see if the value is set already or not and skip the write.
Upvotes: 0


<issue_start>username_0: I am researching to find the best method to work with in order to control the arduino from a web interface (hosted on a web server using PHP) and also sending data from arduino to webserver and save to mySql.

2 methods which I have found that a lot use are save the data to a text file or in the url.

Which is the best or are there any better methods?<issue_comment>username_1: I would suggest your best bet would be to pass messages back and forth via JSON, via Get/Post http request.

So to send data, you send a POST request (to the PHP server) with your data in JSON in the content. To get instructions, you send a GET request to the PHP server and get a contents field with JSON in it.
Upvotes: 3 [selected_answer]<issue_comment>username_2: Another method is to use MQTT. That's a protocol often used for embedded messaging. Find [here](http://knolleary.net/arduino-client-for-mqtt/) the (one of the?) arduino client.

As a server you can install [mosquitto](http://mosquitto.org/) either on the same system running the web server, or on a different one.

Than the communication logic with php will be done with [mosqitto-php](https://github.com/mgdm/Mosquitto-PHP)

advantages:

* decoupling the web server(s) from the arduino(s)
* lightweight protocol for the arduino
* easy interface with more applications (eg, storing data in mysql, independently of the web server, or any new in the future)

disadvantages:

* few more work setting up the mosquitto server.
Upvotes: 1 <issue_comment>username_3: Buy a uart wifi such as WiFly series chip. You can control e chip via UART AT command. The chip capable of sending http post get to/from a server.

See this guide as an example

<http://the.machini.st/posts/35>
Upvotes: 0 <issue_comment>username_4: It sounds like your first need is a way to send the bytes back and forth. A secondary question will be what that data should consist of (eg: text commands, binary commands, etc). Let's tackle the "how" first.

You have described two dynamics to the communication between server and Arduino:

1. The arduino "sends data to the server" where PHP code will save it
to MySQL; if your Arduino can be an internet client (eg: has an
ethernet or wifi interface), it could use GET or POST (or PUT) HTTP calls to
php code. GET is easiest, but normally GET calls shouldn't change the server, only
query it -- but many people make exceptions for small devices and small
amounts of data which can be encoded in the URL.
2. The web server "controls the Arduino". Unless the Arduino sets up
an internet server, it is going to have to poll the web server from
time to time to find out what it should do (ie: to be controlled).
It can pretty easily use a GET to fetch some text which it can
interpret.

I'm guessing that HTTP will be the easiest path for communicating, because you probably understand that if you are a PHP programmer, and because it can often get through firewalls more easily if that matters; but a simple TCP socket or UDP datagrams are also possible.

Once you can send blocks of bytes between the server and the Arduino, you can focus on what those bytes should contain. That could be simple text commands, or some binary protocol, or even the MQTT protocol transactions that another answer references. You haven't given enough info to help select the protocol and format, so I'm assuming you are mostly looking at this time for the method of communicating, as described above. If you want to ask about the format of what to send back and forth once you have the data flowing, please make that a new question. You can test the basics by just sending a "Hello" text string between server and Arduino.
Upvotes: 1 <issue_comment>username_5: If it's not too much data, a textfile as a database should suffice, if you want something more scalable; I'm quite impressed with node.js: <http://weworkweplay.com/play/raspberry-pi-nodejs/>
Upvotes: 0


<issue_start>username_0: I had fun making a 3x3x3 led cube. Now I want to build a bigger one. I'd like to find out the best IC for it. I've seen that some projects uses multiplexer like 4051 or 74HC595.

I'd like to make it at least 8x8x8 (so the multiplexer has to easily be spotted in cascade), possibly supporting also the pwm (to fade the leds).

And I'm a little bit scared by the real time with a lot of LED.. do I have to solve the problem in hardware (with a "faster" multiplexer) o via software?<issue_comment>username_1: Those aren't multiplexing chips. Those are just chips to give you more outputs than your arduino has.

The multiplexing is just done on the microcontroller. But it depends on how you are wiring the leds. You can wire the cube to use less digital outputs, but you'll end up with a less bright leds.

You could use no multiplexing. That way the leds are lid with a 100% duty cycle. But for that you'd need 512 outputs.

You can choose to light up only one level at a time. That way you only need 72 outputs (64 for the leds, and 8 for selecting the level). This is a form of multiplexing. Since only one level is lid at a time, the leds have a duty cycle of 12.5%. Please note that because of the way humans perceive light, it will look more like 1/3rd the brightness, instead of 1/8th (so that's great). Also note that since you only need one level to be on at a time, some people prefer to use a decade counter IC for that.

You could also choose to only light one row at a time. That way you only need 24 outputs (8 for the leds, 8 to select which row, 8 to select which level). But you'd need some additional circuitry to combine row- and level-selection.

There are specialized multiplexing IC, but those only support rows and colums (not level). So you need 1 chip for each level, and more problematically you need to run 8-row and 8-culumn wires for each level to the bottom. That's quite a bit of wire, which might ruin the aesthetics of the cube.

In short. There are quite a few ways of making a 8x8x8 cube. I'd suggest finding a well documented build from someone else that you like and follow that.

Quite a bit of information. I hope it's of help. If you have any more question feel free to ask.
Upvotes: 2 <issue_comment>username_2: You could use a few TLC 5940 PWM Drivers (<http://www.ti.com/product/tlc5940>).

Each one has 16 channels which would mean to power an 8\*8\*8 cube would need 32 Drivers.

However, you can use multiplexing to reduce the number of 5940's you would need.

For example, you could use 4 X 5940's which would give you 64 channels and use 8 X time multiplexing to give you 512 channels.

There are 4096 PWM steps giving you lots of control over brightness and can take up to 17v which should be more than enough for any LED.

One of the added features for the 5940 is because it is a current sink, you dont need a resistor on every LED.

I am currently working on a project with TLC5940's that requires control over 512 RGB LED's meaning I have 1536 individual channels to control
Upvotes: 1


<issue_start>username_0: I would like to control 16 motors with a servo shield, however, I have found scant to nothing sample code online. The one I was able to find is...strange to say the least

<https://github.com/kachok/arduino-libraries/blob/master/Adafruit_PWMServoDriver/examples/servo/servo.pde>

```
#include
#include

// called this way, it uses the default address 0x40
Adafruit\_PWMServoDriver pwm = Adafruit\_PWMServoDriver();

#define SERVOMIN 150 // this is the 'minimum' pulse length count (out of 4096)
#define SERVOMAX 600 // this is the 'maximum' pulse length count (out of 4096)

uint8\_t servonum = 0;

void setup() {
 Serial.begin(9600);
 Serial.println("16 channel Servo test!");

 pwm.begin();

 pwm.setPWMFreq(60); // Analog servos run at ~60 Hz updates
}

void loop() {
 // Drive each servo one at a time
 Serial.println(servonum);
 for (uint16\_t pulselen = SERVOMIN; pulselen < SERVOMAX; pulselen++) {
 pwm.setPWM(servonum, 0, pulselen);
 }
 delay(500);
 for (uint16\_t pulselen = SERVOMAX; pulselen > SERVOMIN; pulselen--) {
 pwm.setPWM(servonum, 0, pulselen);
 }
 delay(500);

 servonum ++;
 if (servonum > 15) servonum = 0;
}

```

Im used to controlling motors using servo.write, but with the shield, it doesn't seem very intuitive as to how I should control the motors. How does Servomin and Servomax map to 0 degree and 180 degree?

Someone please elucidate!<issue_comment>username_1: Adafruit's guide for the shield is here:
<https://learn.adafruit.com/adafruit-16-channel-pwm-slash-servo-shield/using-the-adafruit-library>

I'm not sure how much the library you linked and the official one differ. They seem to be used the same way, but you should probably stick with the official one.

You are going to have to use setPWM(pin, on, off) since the arduino is not generating the signals like it would with servo.write(), the arduino is sending commands to a chip on the shield that generates the signals for you.

Adafruit recommends calibrating SERVOMIN and SERVOMAX yourself with whatever brand of servo you plan on using, but those default values should be pretty close.
Upvotes: 1 <issue_comment>username_2: The 2 values SERVOMIN and SERVOMAX define the pulse length, which tells the servo what angle to go to. The example uses 150 for SERVOMIN and 600 for SERVOMAX. When running the code, the servos travel 180 deg. I changed the code to read:

```
#define SERVOMIN  262 // this is the 'minimum' pulse length count (out of 4096)
#define SERVOMAX  488 // this is the 'maximum' pulse length count (out of 4096)

```

and the servo now moved only 90 deg. centered at the same place as the original code.

the tutorial provided by Adafruit describes a way to define the movement by angle:

```
pulselength = map(degrees, 0, 180, SERVOMIN, SERVOMAX);

```

found here: <https://learn.adafruit.com/adafruit-16-channel-pwm-slash-servo-shield/using-the-adafruit-library>

hope this helps
Upvotes: 3 [selected_answer]


<issue_start>username_0: I understand that el wire and paper needs a special power source known as an inverter to light it up.

If I wanted to control it from an arduino, what point would I connect the arduino to the light or inverter?<issue_comment>username_1: You could connect the Arduino to the light using a relay or any electronic switches (transistors and etc) that can take around 10 to 15mA per meter (so its distance dependent). You could use this link <https://learn.adafruit.com/el-wire/soldering-to-el-wire> to find out where to solder the switch connections to
Upvotes: 0 <issue_comment>username_2: upstream slow blinking
----------------------

The simplest approach:
Use a relay to turn the lights on and off. Control that relay with an Arduino.
("How to turn a relay on and off with an Arduino?" is a separate question).

Cut either one of the wires feeding power into the EL inverter ("upstream of the inverter"),
and connect the 2 cut ends of the (formerly) one wire to the contacts of the relay.

```
power source ---- (relay contacts) ---- EL inverter ---- (EL wire)
           +--------------------------------+    +---------+

```

downstream slow blinking
------------------------

Alternative approach:
Use at least 2 pieces of EL wire.
Wire one always-on;
use a relay to connect or disconnect the other wire ("downstream of the inverter"). (The relay and controlled wire can be either directly connected to the inverter, or end-to-end connected to the always-on wire -- it doesn't matter for this application).

```
                                   always on
power source ---- EL inverter ---- (EL wire) ---- (relay contacts) ---- (EL wire)
           +----------+    +---------+   +-------------------------------+

```

Control that relay to [control the EL wire with an Arduino](http://www.instructables.com/id/Control-EL-Wire-with-an-Arduino/), same as before.

dimming and PWM
---------------

Many low-cost relays are rated for only about 10,000 operations, so if you use them to blink for a long or short part of each second, they're only guaranteed to last for about 3 hours.
If you want to blink faster than that (and most people dim EL lights by blinking them *much* faster than that), you'll have to use something other than a relay.

Also, most people seem to want to do the switching "downstream" of the inverter, so they can "share" a single EL inverter and use it to power lots of independently controlled pieces of EL wire.

Perhaps the simplest approach is to use an off-the-shelf zero-crossing solid-state relay (SSR).
(["How to wire a SSR to an Arduino?"](https://arduino.stackexchange.com/questions/4545/how-do-you-wire-a-ssr-relay-to-a-arduino-nano) is a separate question).

```
power source ---- EL inverter
          +-----------+   | |
                          +----- EL wire (always on)
                          | +-----+
                          | |
                          +----(SSR)-- EL wire
                          | +-----------+
                          | |
                          +----(SSR)-- EL wire
                          | +-----------+
                          | |
                          +----(SSR)-- EL wire
                          | +-----------+
                          | |
                          +----(SSR)-- EL wire
                          | +-----------+
                          | |
                          ... etc.

```

Because most SSRs are overkill for this application -- most of them have heatsinks bonded to high-power triacs designed to handle far more current than we need to light up a EL wire --
some people save a few dollars by assembling their own SSRs out of zero-crossing optocouplers, triacs, etc.
(A lower-cost, low-power triac is more than adequate for controlling EL wire, even without a heatsink).

The SparkFun EL Escudo Dos Arduino shield for controlling electroluminescent wire[(c)](https://www.sparkfun.com/products/10878)[(d)](http://rylaangimby.com/holographic-fortune-teller-arduino-el-wire-unity/);
Diana's SparkFun EL Sequencer[(e)](https://www.sparkfun.com/products/11323)[(f)](http://makezine.com/2010/04/27/programming-el-wire-fashion/)[(g)](http://www.kobakant.at/DIY/?p=2992);
the seeedstudio EL Shield[(h)](http://www.seeedstudio.com/depot/EL-Shield-p-1287.html)[(i)](http://www.seeedstudio.com/wiki/EL_Shield)[(j)](http://www.bajdi.com/trying-out-the-new-seeedstudio-el-shield/)[(k)](http://www.robotshop.com/en/el-shield-arduino.html);
Tully Gehan's Cool Neon Arduino Shield[(m)](http://shopping.netsuite.com/s.nl/c.ACCT88394/it.A/id.1071/.f?sc=2&category=1678)
etc.
uses such zero-crossing optocouplers, triacs, etc.
(requires a separate EL inverter).

According to some people on the Arduino forums talking about EL wire[(n)](http://forum.arduino.cc/index.php?topic=50534.0)[(p)](http://dorkbotpdx.org/blog/paul/sparkfun_el_sequencer_trouble),
some people save a few pennies by using normal optocouplers rather than zero-crossing optocouplers. Non-zero-crossing optocouplers seem to work fine for short pieces of EL wire but seems to destroy the triacs (failing "always on") with a few dozen feet of EL wire.

Some people save a few more pennies by skipping the optocoupler,
wiring the Arduino directly to the control gate of the triac, and the VCC pin of the Arduino directly to the MT1 pin of the triac.
[(q)](https://kavasmlikon.wordpress.com/2011/11/21/how-to-make-el-wire-blink/) [(r)](https://electronics.stackexchange.com/questions/25295/arduino-triggering-a-triac-for-el-wire-no-optoisolator) [(s)](http://celestialaudio.com/catchall/) [(t)](http://www.opencircuits.com/Russ_Hensel's_EL_Wire_Project)
If there were some way to only turn the triac on near the zero-crossing, this could work great; but without zero-crossing control, this has the same problems as the above normal non-zero-crossing optocouplers.

always-on
---------

The "extra" always-on bit of EL wire is because some people say
"never run the inverter without at least 1 foot of EL attached"[(a)](https://learn.adafruit.com/el-wire) because running some EL inverters with no load "can damage the inverter"[(b)](https://learn.adafruit.com/el-wire/using-el-wire).
Upvotes: 2 <issue_comment>username_3: For a simpler option, there are Arduino shields for controlling El Wire. Sparkfun makes a couple and they have some sample code and projects.

<https://www.sparkfun.com/products/10878>
Upvotes: 0


<issue_start>username_0: Is there any significant performance trade-off between buttons wired with the internal vs external pull-up/down resistors? I see a lot of tutorials demonstrating the use of external resistors when wiring a simple button, like [this](http://www.arduino.cc/en/Tutorial/Pushbutton) and [this](http://arduino.cc/en/tutorial/button). But since the Arduino/AVR includes internal pull-up resistors, you can wire a button without any external resistor as demonstrated [here](http://arduino.cc/en/Tutorial/InputPullupSerial).

Is there any good reason to complicate your design with an extra resistor?<issue_comment>username_1: I think it depends on the application you're going for. A simple switch probably doesn't need a resistor, since it doesn't require the chip to provide any specific voltage or current.

If you're trying to run an LED or something that requires a specific amount of current or voltage, then you may be better off supplying the power connection & resistor rather than relying on the chip to provide the proper power to the device.

Another situation may be where you're approaching the maximum power output of the chip that you might change to external pull-up/down resistors.
Upvotes: 0 <issue_comment>username_2: If you are using the pin as an input in close proximity to the Arduino there is little reason to use an external pullup.

There are a number of factors to consider.

If the switch is some distance from the chip and/or in a noisy environment it will be more susceptible to interference as the internal pullups are high impedance (20kΩ to 150kΩ depending on model).

If the pin is used as both input & output the pullup can reduce the voltage swing.

In other applications e.g. Raspberry Pi the state of the pin between boot and software initialisation can be significant, but this should not be an issue with Arduino.
Upvotes: 4 [selected_answer]


<issue_start>username_0: I was just playing around a bit and ran into a strange problem. LED 3, 5, 6, 9 and 10 are on, as intended. For some reason LED 0 and 1 are on as well. Can someone explain why this is happening?

```
int ledPins[] = {3, 5, 6, 9, 10};
int pinCount = sizeof(ledPins);

void setup(){
  for (int i = 0; i < pinCount; i++){
    pinMode(ledPins[i], OUTPUT);
  }
}

void loop(){
   for (int i = 0; i < pinCount; i++){
     digitalWrite(ledPins[i], 1);
   }
}

```<issue_comment>username_1: You haven't initialised the other pins at all; or included your circuit, but clearly you have LEDs on more pins than those defined (5 defined, 7 on).

The other LEDs are, therefore, in an undefined state - and may well be attached to pins set 'on' by default in your circuit. You probably need to either move 0/1 off the serial interface or explicitly set them 'off'.
Upvotes: 2 <issue_comment>username_2: The behaviour of your program is undefined because you're reading past the end of your array.

In C/C++, the `sizeof` operator always gives you the size of something in **bytes**. It doesn't directly tell you the number of items in an array. Since `int` is usually 2 bytes for Arduino programming, the `pinCount` variable is actually being initialised to **10** (5 items x 2 bytes each).

The result is that each `for` loop is actually doing 10 iterations. The first 5 iterations are OK, reading correctly from the `ledPins` array. However, the rest of the iterations are reading whatever data happens to be in memory after that. This means it could be trying to initialise and switch on any pin, potentially including 0 and 1.

I can't guarantee that this is the source of the problem, but it's certainly very important to fix.

The solution is quite easy though. Divide the total size of the array by the size of a single element:

```
int pinCount = sizeof(ledPins) / sizeof(int);

```
Upvotes: 5 [selected_answer]


<issue_start>username_0: Without asking an open-ended question, i wish to find the best way (resourcefulness) to execute methods from an arduino based on time.

in a nutshell, every 10 minutes i want functionA() to be called & every 30 minutes, functionB(). At this point i'm unable to specifiy whether a method would need to be called at a less frequent rate, however i wish to assume that one may.

My 2 ideas so far:

* encapsulate the functions a & b inside the NTP client, and execute based on the minutes in an hour

**or**

* use delay() or even the milli() counter with functions a & b below inside the loop.

My main worry of the 2nd option is that the arduino handles time keeping itself, in a long run (lets say 1 year), the arduino will end up with no memory left. Whats is the consensus with this?

Board wise, to be run on Uno & Mega.<issue_comment>username_1: The best solution would be to determine why your Xbee is not being switched into power down mode.

But, if you wish to turn the Xbee power off using the Arduino then there are many ways of doing this. One method is shown on the diagram below {[**from here**](http://www.microchip.com/forums/m697820.aspx)}. This requires two transistors and three resistors. Almost any small transistors would work. Good choices if buying new components would be BC337 / BC817 for T1 and BC327 / BC807 for T2. The first part number in each pair is a through hole part and the second number is the equivalent surface mount part. If buying these try to get the -40 suffix versions, although in this case any version would work OK.

This circuit was drawn for use with a PIC processor controlling a 12V supply, but the Arduino works equally well controlling a 3.7V LiIon supply. The load is shown as a light bulb - that's where you'd connect the XBee.

![enter image description here](https://i.stack.imgur.com/Ll7ah.gif)

Input low turns 1 off which turns T2 off. To enable/disable the XBee you have to raise / lower the input pin.
Upvotes: 1 <issue_comment>username_2: I would use a sleep mode, e.g. PIN sleep, in order to reduce the power consumption of the Xbee. At the hardware level, the XBee uses pin 9 as a control pin. This pin can be used to sleep the radio: setting it to 3,3V (“high” or “asserted”) causes the radio to sleep; setting it to 0V (“low” or “deasserted”) wakes the radio up. You can find some useful hints on the following websites <http://citizen-sensing.org/2013/08/xbee-sleeping/> or <https://www.digi.com/wiki/developer/index.php/Designing_a_Sleeping_XBee_Sensor> or here <http://www.johnhenryshammer.com/WOW2/pagesHowTo/xbeeSeries1.php#index>.
Upvotes: 0


<issue_start>username_0: Can you use `clang`, with `--mpu=arm`, etc. and `avrdude` to program an Arduino Due (Arm Cortex M3)?<issue_comment>username_1: Theoretically, many things are possible. There is an easy way to code Arduino on Xcode with EmbedXCode (<http://playground.arduino.cc/Main/EmbedXcode>), but in C and CPP.

You need a compiler that will compile your Objective-C to for the AVR (if you are using an AVR-based Arduino), this may be difficult to find. Once your code is compiled, then you need to upload it to the Arduino.

So in any reasonable means, it is at least very challenging.
Upvotes: 2 <issue_comment>username_2: Simple version: No, you cannot program Arduino using Objective-C.

Long version:
The Arduino IDE uses avr-gcc as it's compiler, and avr-gcc is a C/C++ compiler, not an Object-C compiler. The Arduino libraries are written in C/C++.

There are other compilers that exist for *AVR* processors, and so it is possible to use other languages for the *AVR*.

However, if you switch to a different compiler for your code, you will not be able to use the Arduino libraries with it, because they are written in C/C++ for the avr-gcc compiler. (It may be possible to compile the Arduino libraries with avr-gcc, and then link them to your code using external language linking methods, but that could be a significant challenge.)

Also, I do not know of any existing Objective-C compilers for AVR; it's possible one may exist, but after a quick web search, I didn't find any.
Upvotes: 2 <issue_comment>username_3: It can be done, however, it is inadvisable. In order to implement this, one must implement the Objective-C runtime, which, though not insurmountable, is very near insurmountable as far as difficulty is concerned. Perhaps someday some brave soul will see fit to grace the world with their custom Arduino Objective-C runtime, but until that day, the rest of us mere mortals have naught to do but wait for the coming of the Objective-C prophet.

If there are any brave souls in the audience who wish to take on this ultimate challenge, then let them. But otherwise, keep the code in C and hold your peace.
Upvotes: 1 [selected_answer]


<issue_start>username_0: I am just running the below DHCPAddressPrinter sketch in Arduino example to setup EthernetShield with MAC and IP

```
#include
#include

// Enter a MAC address for your controller below.
// Newer Ethernet shields have a MAC address printed on a sticker on the shield
byte mac[] = {
 0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02
};

// Initialize the Ethernet client library
// with the IP address and port of the server
// that you want to connect to (port 80 is default for HTTP):
EthernetClient client;

void setup() {
 // Open serial communications and wait for port to open:
 Serial.begin(9600);
 // this check is only needed on the Leonardo:
 while (!Serial) {
 ; // wait for serial port to connect. Needed for Leonardo only
 }

 // start the Ethernet connection:
 if (Ethernet.begin(mac) == 0) {
 Serial.println("Failed to configure Ethernet using DHCP");
 // no point in carrying on, so do nothing forevermore:
 for (;;)
 ;
 }
 // print your local IP address:
 Serial.print("My IP address: ");
 for (byte thisByte = 0; thisByte < 4; thisByte++) {
 // print the value of each byte of the IP address:
 Serial.print(Ethernet.localIP()[thisByte], DEC);
 Serial.print(".");
 }
 Serial.println();
}

void loop() {

 }

```

**After uploading the sketch to arduino,below is the output shown in console**

```
Sketch uses 13,614 bytes (42%) of program storage space. Maximum is 32,256 bytes.
Global variables use 539 bytes (26%) of dynamic memory, leaving 1,509 bytes for local variables. Maximum is 2,048 bytes.

```

**And there is nothing shown in Serial monitor**
This is the image of Ethernetshield's some leds glowing after connecting to Router.
My router is Binatone Wireless ADSL2+ Router.

![enter image description here](https://i.stack.imgur.com/Cp90K.jpg)
![enter image description here](https://i.stack.imgur.com/U7mgM.jpg)

**I checked arp -a**,

```
C:\Users\Radhamani>arp -a

Interface: 192.168.1.6 --- 0x3
  Internet Address      Physical Address      Type
  192.168.1.1           6c-fd-b9-24-c6-fe     dynamic
  192.168.1.255         ff-ff-ff-ff-ff-ff     static
  172.16.58.3            01-00-5e-00-00-16     static
  192.168.3.11           01-00-5e-00-00-fb     static
  192.168.3.11           01-00-5e-00-00-fc     static
  172.16.31.10       01-00-5e-7f-ff-fa     static
  255.255.255.255       ff-ff-ff-ff-ff-ff     static

Interface: 192.168.198.1 --- 0xe
  Internet Address      Physical Address      Type
  192.168.198.255       ff-ff-ff-ff-ff-ff     static
  172.16.58.3            01-00-5e-00-00-16     static
  192.168.3.11           01-00-5e-00-00-fb     static
  192.168.3.11           01-00-5e-00-00-fc     static
  172.16.31.10       01-00-5e-7f-ff-fa     static

Interface: 192.168.234.1 --- 0xf
  Internet Address      Physical Address      Type
  192.168.234.255       ff-ff-ff-ff-ff-ff     static
  172.16.58.3            01-00-5e-00-00-16     static
  192.168.3.11           01-00-5e-00-00-fb     static
  192.168.3.11           01-00-5e-00-00-fc     static
  172.16.31.10       01-00-5e-7f-ff-fa     static

```

**Complete result of ipconfig:**

```
Wireless LAN adapter Wi-Fi:
   Connection-specific DNS Suffix  . :
   Link-local IPv6 Address . . . . . : fe80::901:3297:48ad:9e7d%3
   IPv4 Address. . . . . . . . . . . : 192.168.1.6
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . : 192.168.1.1
Ethernet adapter VMware Network Adapter VMnet1:
   Connection-specific DNS Suffix  . :
   Link-local IPv6 Address . . . . . : fe80::c954:40b2:c8c1:de0%14
   IPv4 Address. . . . . . . . . . . : 192.168.198.1
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . :
Ethernet adapter VMware Network Adapter VMnet8:
   Connection-specific DNS Suffix  . :
   Link-local IPv6 Address . . . . . : fe80::2837:7e01:c799:d627%15
   IPv4 Address. . . . . . . . . . . : 192.168.234.1
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . :

```

Serial.println in the program is not printing anything.Looks like Ethernet shield is not getting IP.I am not sure where I am wrong.Please help me to fix this issue<issue_comment>username_1: Based on the image .. i see that the programmer pins at the back of the shield and the arduino aren't connected properly.. That might be the error or at least happened with me.
Apart from that, certain network need to identify the mac address from a look up table and if the shield mac address matches, then only network transactions are allowed.
Also i suggest you to drop the virtual machine mac address and networking protocols and try upon the base OS which you have on your computer.
Upvotes: 2 <issue_comment>username_2: The SD might need disconnecting. Add below to setup().

```
pinMode(10, OUTPUT);
digitalWrite(10, HIGH);

```

Also check the pin assignment for the W5100 (in the Ethernet library).

Cheers!
Upvotes: 0 <issue_comment>username_3: check the DHCP service of your router is active or not :)
Upvotes: 0 <issue_comment>username_4: I had the same problem and it had two causes:

1) I couldn't fully insert pins of my shield into the board (ArduinoMega), because if its USB connector. So I connected them with cables. To check for this error, use this code to initialize your Ethernet shield:

```
   Ethernet.begin(mac, ip);
   if (Ethernet.begin(mac) == 0) {
     Serial.println("Failed to configure Ethernet using DHCP");
     Ethernet.begin(mac, ip);

     if (Ethernet.hardwareStatus() == EthernetNoHardware) {
       Serial.println("Ethernet shield was not found.");
     } else if (Ethernet.linkStatus() == LinkOFF) {
       Serial.println("Ethernet cable is not connected.");
     }
   }

```

If this is the case, it will print "Ethernet shield was not found."

2) I'm using this Chinese W510 shield too (the same as on the photo above). Apparently, there's a known bug. Here is the solution: <https://forum.arduino.cc/index.php?topic=351477.45>

In short: You have to solder 2 resistors between pins 1-2 and 3-6 of the shield's Ethernet connector. No need to unsolder anything.

Works great!
Upvotes: 0


<issue_start>username_0: I have a code with a connection to serial port:

```
// Set baud rate
UBRR0H = UBRRH_VALUE;
UBRR0L = UBRRL_VALUE;
// Disable USART rate doubler (arduino bootloader leaves it enabled...)
UCSR0A &= ~(1 << U2X0);
// Set async, no parity, 1 stop, 9bit
UCSR0C = (0<
```

I see the comments but I want to know exactly what does these chunks means. Is there any complete documentation about these symbols?<issue_comment>username_1: Take a look in the datasheet under the "20. USART0" section:

<http://www.atmel.com/images/Atmel-8271-8-bit-AVR-Microcontroller-ATmega48A-48PA-88A-88PA-168A-168PA-328-328P_datasheet_Complete.pdf>

I will list the names of the registers, what they are called, and then what your code is doing specifically:

* UBRR0H and UBRR0L together form the baud rate divider. Your program probably uses F\_CPU and  to calculate a divider and set the baud rate. For more information see Table 20-12.
* UCSR0A "USART Control and Status Register n A" -- This line is enabling the U2X0 which doubles the transmission speed
* UCSR0C "USART Control and Status Register n C" -- This line is enabling the UCSZ01 and UCSZ00 bits to set parity check to "Enabled, Odd Parity". See Table 20-9. This line has extra information, all the statements with 0<< actually do nothing.
* USCR0B " USART Control and Status Register n B" -- This line is setting the UCSZ02 bit which is described here: "The UCSZn2 bits combined with the UCSZn1:0 bit in UCSRnC sets the number of data bits (Character SiZe) in
a frame the Receiver and Transmitter use. " This basically allows you to select 9 bit wide serial if you would like (8 bit is more common)
* The final USCR0B line enables tx and rx
Upvotes: 4 [selected_answer]<issue_comment>username_2: I strongly recommend you to read the datasheet. You are confusing UART module with GPIO module. Once you use one pin for one purpose (say serial comunication) you cannot use it for another thing (say general I/O to read a physical button state). Of course it is possible if you write your code in a way it changes all the registers (the ones you call "symbols") on excecution time. But just be carefull that the routines that used those pins for UART don't execute meanwhile!
Upvotes: 0


<issue_start>username_0: I have an Arduino Uno R3 and when I plug it into any computer, the computer doesn't recognize the Arduino. I checked up and the LEDs are working fine and when I open the device manager it doesn't show any `Unkown Device`.

What it could be? Could the ATMega be dead? I tried on two Windows 7 and one Linux machines, none recognized the Arduino.<issue_comment>username_1: The reason that it is not connecting can be anything from wrong driver installation to the dead Atmega 16u2 chip. But I must exclude the former option as you said you'd tried on different OS and different computers. So double check the driver installation. And if does not work try to find out whether Atmega16u2 is fried or not. One solution might be to reflash the original firmware through an external ICSP programmer. If don't have any programmer but another arduino uno you might try out the gamon's tutorial on flashing firmware on the little USB to serial interface chip.
Anyway if your arduino is new and official you can get the right support online on arduino.cc. but if it is a clone you may try to contact the reseller whom you bought from.
Upvotes: 2 <issue_comment>username_2: I had the same problem. When I connected the board to PC the ON Green LED turned on and the arduino run the last code was uploaded but the board wasn't recognized. Changing the cable fixed this problem for me.
Upvotes: 0 <issue_comment>username_3: If your arduino runs the last uploaded sketch, the problem is with the ATMega16U2 chip in your Arduino. Try to update the firmware with this tutorial <https://www.arduino.cc/en/Hacking/DFUProgramming8U2>

If you can't update the 16U2 firmware don't throw away, you can program the Arduino with a ISP programmer like this <https://www.pololu.com/product/1300>
Upvotes: 0


<issue_start>username_0: I accidently bought a "Common Anode" 7-segment display instead of a "Common Cathode".

I understand that the polarity of the leds within the display is 'reversed'. So instead of putting the common pin on GND I have to put it to 5v (with current limiting resistor)

My questions on this are:

1. Can I still use only one current limiting resistor on the common pin? Instead of a resistor on every segment pin.
2. Can I use the pins from arduino to drive it (withouth pull-up/pull-down?) By making the signal `LOW` the current will flow from 5V common anode to the arduino and thus the segment wil light?
3. Can I still use a shift register to drive the segment led? (By inversing the outputs (in software))

---

**Obviously I would like to have wiring more like this** (but then I would ofcourse change the GND line to a 5V line.

![Better wiring](https://i.stack.imgur.com/S6MnF.jpg)

---

**The wiring below is the worst-case wiring I can think of.**

![Wiring](https://i.stack.imgur.com/t9mfh.png)

^ So can I avoid this, when using a `Common Anode 7-segment display` or am I forced to buy a `Common Cathode 7-segment display`?<issue_comment>username_1: You can use a single resistor on the common pin if you want. The problem is that lighting up multiple segments at the same time will substantially reduce the brightness of each one. You could work around that by lighting each segment one at a time in very quick succession though.

It should be possible to control the display directly from the IO pins by setting them LOW. In this configuration, they will be **sinking** current (rather than **sourcing** it). It depends on the specification of the display and on what resistor you use though.

Basically, try to keep the current **below 20mA** and it should be OK (assuming you're using a standard 5V Arduino). For example, if each segment has a forward voltage drop of 2V, you would want to use a resistor of around 180 Ohm.

Controlling the display directly from a shift register is probably not possible, although once again it depends on its specification. Shift registers usually aren't designed to sink enough current so you'll need something like a transistor on each output.
Upvotes: 3 [selected_answer]<issue_comment>username_2: Sorry about the crudity of my image, but you don't always need those transistors. Peter has already said so, but I wanted to explain a bit further.
![schematic](https://i.stack.imgur.com/01Y8C.png)

The only thing is that you need to set a pin to LOW to light up the led, and HIGH to turn it off. Just use a `!` to make your code more intuitive if your like. So e.g. `digitalWrite(segmentA, !HIGH)`

Some limitations. A pin can sink up to 40mA (no problem here), but the total sink current for the digital pins `0` to `4` shouldn't exceed 100mA. The same goes for pins `5` to `13`. And the same goes for the analog pins. So either limit the current through the leds to around 10mA, or make sure no more than 5 leds are lit at the same time, or connect half of the segments to on of the above mentioned groups, and the other half another (f.y.i. analog pins can be used just like digital pins).
Upvotes: 2 <issue_comment>username_3: Peter and username_2 have already said what is needed , but I wish to explain things even further.

A normal small 7-Segment display consumes only **70-80mA** when all segments are HIGH.So you can use the Arduino directly without damaging it. Also note, depending on the quality of the project, you could either use a common resistor for all segments, or use separate ones. Separate ones will give much brighter light and better quality.

A medium size one will require max consumption of around **400mA** current, so use cheap transistors.

A large size one will require max consumption of upto **1.5-2A** current , so use MOSFETS or other high current Transistors.

An Extra Large one will require max consumption of upto **10-25A** current, so use good MOSFETS or maybe even Relays.

***Usage**

Small- Wrist watches

Medium- Small clocks

Large- Big clocks

Extra Large- Very big clocks like ones in Railway stations*
Upvotes: 1


<issue_start>username_0: I'm looking to develop my own personal SmartWatch, hardware, software, and all. My problem is starting off on the hardware portion of it; more specifically what platform I should build it on. I already have an Arduino Uno (R3), nut I was hoping to find something a bit smaller. Any recommendations on what parts I should use?<issue_comment>username_1: What you start with is not too critical as you can develop basic concepts on any Arduino hardware and use it to drive a display of your choice for testing. This can be migrated to whatever is found suitable as the project progresses.

Important to consider are the number of I/O lines of various sorts that you need. Most AVR ICs that you are liable top use will have "some" analog input and PWM output lines. If you were going to drive a "bare" LCD you may need to use a processor with LCD drivers, but in most designs use of an existing module with eg SPI interface is probable preferable.

Most Arduinos in the UNO, Nano, Pro Mini, ... range are in reality not a lot more functionally that a processor IC, USB bridge (if needed) and voltage regulator(s). For a tidily small watch you may ultimately wish to use a bare SMD AVR IC with an Arduino boot loader code installed. You can move away from AVR ICs to other Arduino compatible systems - with some extra knowledge needed in most cases.

.\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_

**Examples only:**

Here is an [**Internet of things hardware roundup**](http://postscapes.com/internet-of-things-hardware) which includes some small controllers as examples.

[**Panstamps**](http://www.panstamp.com/) offer MSP430 and ATMega328p (Arduino compatible versions).

![enter image description here](https://i.stack.imgur.com/YdzzS.jpg)

. \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_

[**RFDuino - from here**](http://www.rfduino.com/) offer some fingertip sized products with RF capability. Note that this use an ARM Cortex M0 processor, not an ATMega controller. While it is "Arduino compatible" it will not run all code that the typical UNO, Nano, ... boards run.

[Manual here](http://www.rfduino.com/wp-content/uploads/2014/04/RFduino.Quick_.Start_.Guide_.pdf)

[![enter image description here](https://i.stack.imgur.com/bZXdw.jpg)](https://i.stack.imgur.com/bZXdw.jpg)

[Their Kickstarter page](https://www.kickstarter.com/projects/1608192864/rfduino-iphone-bluetooth-40-arduino-compatible-board)
Upvotes: 4 [selected_answer]<issue_comment>username_2: Why not start with your Arduino Uno, it's got lots of I/O pins, and it's a great little device to start prototyping your watch.

You could add a number of sensors/peripherals such as

* a Bluetooth module, - connect your phone
* an IMU, - detect different excercises from your wrist movement
* a tiny motor - to make the watch vibrate
* a speaker for audible notifications
* tactile buttons for switch between modes and functions of the watch
* a LCD screen, - to see the time and other data
* maybe a few LEDs as a torch function.

Once you develop your code and your happy with it, you could shrink your board accordingly, because you will then know how much I/O pins you'll need, and what voltage these sensors need to operate, and their inputs (analog vs. digital). You could even design your own PCB board with all these sensors.

You could use the Uno as a stepping stone.
Upvotes: 2 <issue_comment>username_3: I have quite a few nanos / mini pros that I got as plain avr boards. they are great little things.

I also got a few minimus avr - if you want to venture outside of arduino. like the at90 usb stick / key, they are little boards that are 100% self-contained. they are ideal to play with on long flights.
Upvotes: 0 <issue_comment>username_4: One Possibility is that you could just use an avr chip without the arduino breakout, but still include the arduino bootloader, and this way it would be easier for you to isolate your preferred features, however with this method you would be sacrificing some safety without short circuit protection, and it would be a bit more work to upload, but this is also the cheapest.
Upvotes: 1 <issue_comment>username_5: Have a look at the LilyPad ([Main Board](https://www.arduino.cc/en/Main/ArduinoBoardLilyPad), [USB](https://www.arduino.cc/en/Main/ArduinoBoardLilyPadUSB), [Simple](https://www.arduino.cc/en/Main/ArduinoBoardLilyPadSimple)) and [Gemma](https://www.arduino.cc/en/Main/ArduinoGemma). The Gemma may have too few I/O pins for your needs, but it really does look small.
Upvotes: 1


<issue_start>username_0: I have put together a breadboard version of the arduino by following the tutorial on arduino's main website <https://www.arduino.cc/en/Main/Standalone>.

I have done everything exactly how that tutorial explains it and have double checked my work to ensure I didn't mess up a connection somehow. I have a usb mini breadout board that I am connecting from the breadboard to my computer and the pin outs are as follows:

* GND -> Breadboard GND
* 5v -> Breadboard + rail
* TXO -> IC pin 2
* RXI -> IC pin 3
* GND (GRN) -> IC pin 1 through .1μF cap

When I go to the arduino IDE and select the arduino duemilanove setting and upload a sketch I come out with this error:

```
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding

```

I am using a pre-bootloaded atmega328 chip and have switched it out with two others to make sure it wasn't the switch, but that didn't help either.

Any ideas on what might be the problem?<issue_comment>username_1: The internal pull-up is around 50k. So, install an external pull-**down** (to ground) of a somewhat higher value, like 1M.

Now:

Go to input mode, no pull-up. Get a reading. Turn on the internal pull-up. This should overpower the pull-down. If the reading **changes**, it was tri-state. Otherwise, if the reading doesn't change the external device is overpowering both pull-up and pull-down and you have the actual reading.

You may need a slight delay to allow the low-value pull-down to change the pin state.

---

Amended code to demonstrate:

```C++
// PART (2) Code to determine state of tri-state pin
Serial.print(stateCh);     // Shows what it *should* be

pinMode(pinTest, INPUT);
delayMicroseconds (100);
byte firstReading = digitalRead(pinTest);
pinMode(pinTest, INPUT_PULLUP);
delayMicroseconds (10);
byte secondReading =  digitalRead(pinTest);

if (firstReading != secondReading)
  Serial.println(" - HiZ");
else if (secondReading == HIGH)
  Serial.println(" - HIGH");
else
  Serial.println(" - LOW");

```

(Only showing the part that detects the pin state, the rest is the same).

Output:

```none
H - HIGH
L - LOW
Z - HiZ
Z - HiZ
Z - HiZ
H - HIGH
H - HIGH
H - HIGH
H - HIGH
H - HIGH
H - HIGH
H - HIGH
L - LOW
Z - HiZ
Z - HiZ
Z - HiZ
H - HIGH
H - HIGH
H - HIGH
H - HIGH
H - HIGH
H - HIGH
H - HIGH
L - LOW
Z - HiZ
Z - HiZ
Z - HiZ
H - HIGH
H - HIGH
H - HIGH

```

As you can see, working perfectly. I needed a longer delay after turning the internal pullup **off** because the fall time was around 100 µs. This actually sounds reasonable, because the 1 megohm resistor will take time to discharge the capacitance on the pin.

So:

* 10 µs delay after turning the internal pull-up **on**
* 100 µs delay after turning the internal pull-up **off**

---

**Theory for the delays**

The Atmega328 pin is specified as having a maximum capacitance of 10 pF (10e-12). It is considered charged/discharged after 5 time-constants, where `T = R.C`.

Thus for an internal pull-up resistance of 50k and a capacitance of 10 pF, charging should take:

```none
50e3 * 10e-12 * 5 = 2.5e-006 (0.0000025) -> 2.5 µs

```

And to discharge through 1M (1e6) ohms, discharging should take:

```none
1e6 * 10e-12 * 5 = 5e-005 (0.00005) -> 50 µs

```

My observed results were about 2.5 µS for the charge, but more like 100 µs for the discharge, however I probably had considerable stray capacitance in the wires used in the test circuit.
Upvotes: 4 [selected_answer]<issue_comment>username_2: Another option is to use an analog input pin instead of a digital input pin.

Create a balanced voltage divider using equal high value resistors (say 100KΩ each). Attach the mid-point to the ADC pin, and one end to each of Vcc and GND. The incoming status signal goes to the ADC pin:

![enter image description here](https://i.stack.imgur.com/a2lw6.png)

Perform an analogRead() on the pin. You will get one of 3 results:

* Close to 0 = LOW
* Close to 1024 = HIGH
* Close to 512 = HiZ

When the pin is in HiZ the resistors will hold the voltage at around 50% of Vcc. When the pin goes HIGH it will pull the pin up and override the resistors, giving a high value reading. Similarly, when the pin goes low, the resistors will be overridden and a low value reading will be given.
Upvotes: 2 <issue_comment>username_3: For the 1M pulldown solution, turning off the internal pullup at the end of the pin check routine MIGHT give enough time for the pin to discharge, and it might not if the code can conditionally do very little else between pin checks. If you want to leave out the 100 us delay, take care to ensure that your code will always do something that takes sufficient cycles for the pin to discharge between checks.
Upvotes: 0 <issue_comment>username_4: username_1's answer seems the most straightforward solution to your
problem, given that you cannot spare an analog input. It has however the
drawback of needing a delay of ≈ 100 µs. This may not be an
issue, but I just figured out a scheme that allows a faster read, and
may be of interest to some: instead of pull-ups or pull-downs, put just
a 10 kΩ resistor *in series* between the MPC73831's output and you
Arduino input. When you want to read the state:

1. Take a first reading with the pin in INPUT mode:
	* if you read HIGH, then your MPC is either HIGH or HI\_Z
	* if you read LOW, then it's either LOW or HI\_Z
2. Now, switch the pin to OUTPUT, write the *opposite* of what you just
read, switch back to input and take a second reading:
	* if you read what you just wrote, then your MPC is in the HI\_Z state
	* if you read the same as before, then it's either HIGH or LOW.

Here is the implementation of this scheme:

```c++
#define HI_Z 2

/*
 * Read a 3-state pin.
 * Put a 10 kOhm resistor between the output and input pins.
 */
int read3state(int pin)
{
    int reading1 = digitalRead(pin);
    pinMode(pin, OUTPUT);
    digitalWrite(pin, !reading1);
    pinMode(pin, INPUT);
    int reading2 = digitalRead(pin);
    if (reading1 == reading2)
        return reading1;
    else
        return HI_Z;
}

```

I have tested this a few 104 times with an Arduino sending to
itself a pseudo-random sequence of LOW, HIGH and HI\_Z. It works
reliably for me.

**Caveat**: This scheme relies on the pin being capacitively coupled to
GND or Vcc, and this coupling being stronger than couplings with other
signals in your circuit. If you fear this might not be the case, you can
put something like 100 pF from the pin to ground, but then you
should better wait a couple of microseconds before taking the second
reading.
Upvotes: 0


<issue_start>username_0: I have an LED strip that I am trying to turn on with a magnetic switch when a door opens. I want the LEDs to fade on when I open the door and fade off when I close it, which is where the Arduino comes in. I am using PWM for the fading. I can get each component to work separately. The fading LEDs work with the MOSFET without the switch. I tested the switch with serial output on the Arduino and it works fading a single LED without the MOSFET.

I am using:

* Arduino Uno R3
* Magnetic Switch
* N-Channel MOSFET IRLB3034
* 5 Meter White LED Strip
* 12VDC 30W Power Supply
* 10k Ohm Resistors

My setup looks like this:
![breadboard diagram](https://i.stack.imgur.com/lDJYg.png)

Schematic:
![schematic](https://i.stack.imgur.com/y3mX4.png)

Code (if it helps):

```
const int buttonPin = 2;     // the number of the switch pin
const int ledPin =  9;      // the number of the LED pin

// variables will change:
int buttonState = 0;         // variable for reading the switch status
int brightness = 0;
int fadeAmount = 5;

void setup() {
  // initialize the LED pin as an output:
  pinMode(ledPin, OUTPUT);
  // initialize the pushbutton pin as an input:
  pinMode(buttonPin, INPUT);
}

void loop(){
  // read the state of the switch value:
  buttonState = digitalRead(buttonPin);

  // check if the switch is ON.
  // if it is, the buttonState is LOW:
  if (buttonState == LOW) {
    // fade LED on:
    analogWrite(ledPin, brightness);
    if (brightness < 255) {
      brightness = brightness + fadeAmount;
    }
  }
  else {
    // fade LED off:
    analogWrite(ledPin, brightness);
    if (brightness > 0) {
      brightness = brightness - fadeAmount;
    }
  }
  delay(30);
}

```

I have a feeling the problem is with the common ground on the MOSFET and the switch. Any solutions/suggestions are appreciated.<issue_comment>username_1: There is no need for the 10KOhm. MOSFETs are voltage controlled devices unlike transistors which need controlled current. I think your problem might be in debouncing of switch. You are probably getting some false positives which might be making your software go awry.
I recommend having a small debouncing routine. For eg - only if you find 3 successive positives will the switch press be termed a true positive or so.
Upvotes: 0 <issue_comment>username_1: I think you should keep the R2 resistor, but make it 1k and put before it a pull-down resistor of 10k so that any charges stored in the NMOS Cgate capacitance are discharged, whenever there is High-Z at the port D9. Also never forget the resistor limiting the diode forward current, which is typically 20 mA, but you should check that every time in datasheet. In case of LED strip there are usually internal resistors, but if you are using higher voltage still you need to restrict the current. Could you tell us more about why you are using PWM not a simple output port with an integrator for example and what you exactly observe and measure when you turn-on-off (fade-on-off) the LED?

![schematic](https://i.stack.imgur.com/FbvYW.png)

[simulate this circuit](/plugins/schematics?image=http%3a%2f%2fi.stack.imgur.com%2fFbvYW.png) – Schematic created using [CircuitLab](https://www.circuitlab.com/)

How to make the diagram a bit smaller?
Upvotes: 1


<issue_start>username_0: I have been using a **Make-It Robotics kit**, that I picked up from a RadioShack that was closing, to learn more about Arduino, C, etc. After building the **line-following robot** and downloading the correct libraries, I can get the robot to function as intended. It uses 2 optical sensors in front of 2 driving wheels that are controlled by independent DC motors. The optical sensors determine if the left or right side of the front of the robot is over a white or black area on the test track. The necessary motor then turns on to keep the black line roughly between the 2 sensors as the robot moves along. The default test track that came with the kit was a large black circle on a white background.

I want to make some modifications to the code (and maybe the underlying library files) to try to make the robot able to handle other types of paths with more acute angles and sharper turns, etc. But, I don't understand some aspects of the highest level .ino source code file.

I am a little unsure of pasting such a long code block below and also don't think an image of it will help. The version data for the file I'm using is below. The files can be found online @ [LINK](https://github.com/RadioShackCorp/2770168-MakeItRobotics-Starter-Kit/blob/master/2770168%20Starter%20Kit/linefollow/linefollow.ino)

```
// ******************************************************************************    **
// * File Name          : linefollow
// * Author             : RadioShack Corporation
// * Version            : V1.0
// * Date               : 2014/01/16
// * Description        : Optical sensors send feedback to PCB
// *                      to make the robot follow a black line on a white background.
// ********************************************************************************

```

In this .ino file, **I don't understand the code from line 68 onwards**: from the Read Left/Right Optical Status onward...

I don't understand some of the bitwise operations there and don't really see how the sensor readings (whether it is over a white or black area on the surface) correlates to which motor activates to keep the robot on the course...

From my limited understanding of Arduino, this robot kit, and the code, it seems like the software and hardware have to interact in this way:

1. Robot moves forward using both motors turning the wheels in the same direction. It approaches the black test circle at a shallow angle (i.e. almost tangent to it) to allow one sensor to go over the black line before the other one does.
2. Optical readings of each sensor are taken periodically.
3. If both sensors detect white space, robot continues to move forward.
4. If the right sensor detects that it has gone from white to black and then to white, it means that the robot needs to turn to the left to stay on the path.
5. To turn left, the left motor is un-powered and the right motor is powered until the right sensor detects black again.
6. Now that the robot is on course, it will keep turning in the direction of the sensor that detects a white to black to white transition.

I am not seeing how my intuitive understanding of the robot's operation matches with that of the code...<issue_comment>username_1: Indeed, the way the bitwise operations are written is confusing.

```
  if((sensor_in & 0xf00)==0)
    sensorValue1=sensor_in & 0xff;
  else if((sensor_in & 0xf00)>>8==1)
    sensorValue2=sensor_in & 0xff;
  if (sensorValue1 == 0x00)
    action1 =action1 & 0xfe;
  if (sensorValue1 == 0xFF)
    action1 = action1 | 0x01;
  if (sensorValue2 == 0x00)
    action1 = action1 | 0x02;
  if (sensorValue2 == 0xFF)
    action1 = action1 & 0xfd;

```

Basically you have two input values that can be in the same variable - differentiated by the 9th bit of the value. Values between 0 and 255 relate to one sensor, between 256 and 511 to the other. The bitwise operators split that into sensorValue1 and sensorValue2 accordingly.

Then those sensor values are compared to 0 or 255 and used to define the action to perform - that action being comprised of the lowest two bits of a byte variable, so you have three possible actions:

```
0 = both sensors off
1 = sensor 1 on, sensor 2 off
2 = sensor 1 off, sensor 2 on
3 = both sensors on

```

The comments in the program also tell you this information:

```
action1
         left        right
0x00    black        black
0x01    black        white
0x02    white        black
0x03    white        white

```

Now you have how to deal with the action value:

```
if(action1 != action2)
{
  if (action1 == 3 )
    line_following.go_forward(50);
  if (action1 == 1)
    line_following.line_following_turn_left(50);
  if (action1 == 2)
    line_following.line_following_turn_right(50);
  if (action1 == 0)
    line_following.go_forward(50);
}
action2=action1;

```

So if the action has changed, we can change what we are doing:

* If action is 3, so if both sensors read as white, or if action is 0, so both sensors read black (in other words if both sensors read the same) then move forwards.
* If action is 1 (so the left sensor reads black) then turn to the left.
* If action is 2 (so the right sensor reads black) then turn to the right.

So basically if it doesn't know anything better, it drives forwards, otherwise it turns in the direction that it finds the black line, thus keeping it always on that line. As it drifts off the line one sensor will sense white, so the robot will turn away from that whiteness and back on to the line.
Upvotes: 3 [selected_answer]<issue_comment>username_2: In addition to the answer given on this site, I had to do some reading up on what bit-wise operations are and how they are useful. I did most of that reading on the Arduino website reference section.

I also stumbled across an online tech blog that actually dissected the inner workings of this program! The blog's author seemed glad to help Arduino beginners who got this kit, but had trouble understanding how exactly the robot moved in response to the sensor data.

[JoesTechBlog](http://www.joestechblog.com/2014/07/10/makeit-robotics-starter-kit/)

Someone even asked the blog's author about why anyone would code the logic in this manner. I too was wondering the same as to why it wasn't done at a higher (thus easier to understand level). Below is the author's response to that question. Can anyone here comment on it in terms of its veracity?

>
> Hello Richard, Yes I agree this logic is non-intuitive. I would have done the >logic on the mirco-controller, that lives on the driver board, and just had >the read\_Optical() method return a 0, 1, 2, or 3. But there is one possible >reason for this logic. Performing bitwise operations in most cases takes up >less CPU cycles than complex number comparisons. Since Radio Shack is not >providing us the source code that runs on the driver board. Then we can only >guess. Also sometimes bare metal programmers think in these terms, which may >seem non-intuitive at times, but the more we start working at the bit level >the more it makes sense.
>
>
> Thanks for the post.
>
>
> Joe
>
>
>
Upvotes: 0